đź’ľ
Cheat Sheet
  • Cheat Sheet
  • Git
    • Initialize a new project
    • Make a new commit
    • Revert the most recent commit
    • Create a new branch
    • Setup terminal prompt to show the current git branch
    • Merge a branch into the current branch
    • Push a new branch up to GitHub (if it doesn’t exist there yet)
    • Pull a new branch from to GitHub to a second computer (if it doesn’t exist there yet)
    • Go back to an older commit and re-work from there
    • Delete a git branch
  • Rails
    • Setup Rails 8 w/ SQLite & Solid Cable, Cache & Queue
    • Stripe Pay Gem
      • Running Stripe Test Mode Locally
    • Setup new Rails app
      • Start a new Rails App (v8)
      • Start a new Rails App (v7)
      • Clone Instrumental Template to a new app
    • Rails 7 Turbo/Hotwire Cheatsheet
    • ActiveStorage with AWS S3
    • Live reloading with webpack-dev-server
    • Sidekiq & Redis
      • Setup Sidekiq in a Rails 8 app
      • Clear sidekiq queue
      • Start jobs worker
    • Setup Solid Queue/Cable/Cache in Rails 8 to share a single database
    • Run rspec tests
      • ZipMessage Tests Commands
      • Can't run rspec tests: ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR: relation "thing"
    • Acts As Tenant (using Rails console)
    • Reset database & re-run migrations
    • Ultrahook for testing email to app
    • Troubleshooting
      • Manage node versions using NVM
      • Webpacker bugs
      • Tailwind updates not showing
      • Fix orphaned migrations
      • rspec error: session not created: This version of ChromeDriver only supports Chrome version
      • “PG::ConnectionBad” error when running local rails server
        • Postgres not started (PG:ConnectionBad error)
    • OLD
      • Start a new Rails app (v6)
        • Install Tailwind CSS on a Rails Project
        • Install Stimulus.js on Rails
        • Install RSpec, Capybara, FactoryBot
        • Install Devise Masqerade
    • Hosting
      • Hatchbox.io + Digital Ocean
      • Fly.io rails app hosting
      • Render rails app hosting
      • Set up a Rails site on Heroku
        • Fix Sidekiq on Heroku
        • Setup app on Heroku for a Client
    • Edit Rails Credentials
    • Run subdomains on local
  • Misc
    • Terminal shortcuts
    • ngrok for tunneling
    • Set up a new Mac
    • Mailcatcher
  • Statamic
  • Forge / Statamic
    • Run Statamic (for Clarityflow) locally
    • Set up to SSH into Forge server
    • Production deploy failed. Resolve by SSH & resolve git conflicts.
  • Old (not using anymore)
    • Heroku
      • Push to Heroku
        • Can't push to heroku. Updates were rejected because the remote contains work you dont have locally
      • Create a Heroku App from command line
      • Set up remotes for staging and production apps
      • Run the Rails Console on Heroku
      • Migrate database on Heroku
      • Make database backups
      • Restart Heroku Dynos
      • Point a root domain (non-subdomain) to heroku
    • Middleman
      • Start a new middleman site from my template
    • Jekyll
      • Start a new Jekyll site from my template
      • Run and work on my Jekyll site
    • Netlify
      • Setup a Jekyll site on Netlify
      • Push to Staging & Production on Netlify
    • Laravel
      • Start a new Laravel app
      • Setup a Mac for running Laravel
    • Design
      • Icomoon Fonts in Rails
    • Sync Sublime Text settings across macs
    • Run a rails project on a new mac for the first time
    • Customize terminal prompt for bash
  • Cursor
    • .cursorrules for Rails + Linear issue writing
  • Mac Environment
    • Install Homebrew for both arm64 and x86
    • Installing Ruby
    • Customize terminal prompt for zsh to show git branch
    • Open terminal in arm64 or Rosetta mode
    • Install Homebrew
Powered by GitBook
On this page
  • Install Tailwind
  • Create the stylesheets folder and application.scss file
  • Drop in the Tailwind styles
  • Require the stylesheet in app/javascripts/packs/application.js
  • Add the stylesheet_pack_tag to the head
  • Update postcss.config.js
  • Generate the Tailwind config file
  • Create a full version of the Tailwind config so you can reference it
  • Add my custom utilities CSS
  1. Rails
  2. OLD
  3. Start a new Rails app (v6)

Install Tailwind CSS on a Rails Project

PreviousStart a new Rails app (v6)NextInstall Stimulus.js on Rails

Last updated 4 years ago

This was found in this GoRails guide:

Install Tailwind

yarn add tailwindcss

If when running the server tailwind is not working and you see this JS error: Error: PostCSS plugin tailwindcss requires PostCSS 8. it means you will need to run this ()

npm uninstall tailwindcss postcss autoprefixer
npm install tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9

Create the stylesheets folder and application.scss file

Create this file and folder:

app/javascript/stylesheets/application.css

Drop in the Tailwind styles

From Tailwind docs:

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

Require the stylesheet in app/javascripts/packs/application.js

In app/javascripts/packs/application.js add this line:

require("stylesheets/application.css")

Add the stylesheet_pack_tag to the head

This should be present in addition to the stylesheet_link_tag. This will ensure that styles from webpack (inside app/javascript/stylesheets) get compiled and included.

<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

Update postcss.config.js

Add this line below require('postcss-import')

If it is not below postcss-import, then @apply rules won't work in the CSS files.

require('tailwindcss'),

Generate the Tailwind config file

This will create the empty tailwind.config.js file in the project root. This is where you will place configs to override Tailwind's defaults.

npx tailwind init

Create a full version of the Tailwind config so you can reference it

This will be used to reference and copy/paste settings that you want to override inside tailwind.config.js.

npx tailwind init tailwind-full.config.js --full

To override any config settings, place those overrides inside the theme: { ... } section in tailwind.config.js

Add my custom utilities CSS

Create another file at app/javascript/stylesheets/global/custom-utilities.scss

Reference this file in application.scss, in between tailwindcss/base and tailwindcss/components:

@import "global/custom-utilities.scss";

These are my common custom utilities to include in custom-utilities.scss:

.top-1 { top: 1px; }
.top-2 { top: 2px; }
.top-3 { top: 3px; }
.top-4 { top: 4px; }
.top-5 { top: 5px; }
.top-6 { top: 6px; }
.top-7 { top: 7px; }
.top-8 { top: 8px; }
.top-9 { top: 9px; }
.top-10 { top: 10px; }
.top-11 { top: 11px; }
.top-12 { top: 12px; }
.top-13 { top: 13px; }
.top-14 { top: 14px; }
.top-15 { top: 15px; }
.bottom-1 { bottom: 1px; }
.bottom-2 { bottom: 2px; }
.bottom-3 { bottom: 3px; }
.bottom-4 { bottom: 4px; }
.bottom-5 { bottom: 5px; }
.bottom-6 { bottom: 6px; }
.bottom-7 { bottom: 7px; }
.bottom-8 { bottom: 8px; }
.bottom-9 { bottom: 9px; }
.bottom-10 { bottom: 10px; }
.bottom-11 { bottom: 11px; }
.bottom-12 { bottom: 12px; }
.bottom-13 { bottom: 13px; }
.bottom-14 { bottom: 14px; }
.bottom-15 { bottom: 15px; }
.left-1 { left: 1px; }
.left-2 { left: 2px; }
.left-3 { left: 3px; }
.left-4 { left: 4px; }
.left-5 { left: 5px; }
.left-6 { left: 6px; }
.left-7 { left: 7px; }
.left-8 { left: 8px; }
.left-9 { left: 9px; }
.left-10 { left: 10px; }
.left-11 { left: 11px; }
.left-12 { left: 12px; }
.left-13 { left: 13px; }
.left-14 { left: 14px; }
.left-15 { left: 15px; }
.right-1 { right: 1px; }
.right-2 { right: 2px; }
.right-3 { right: 3px; }
.right-4 { right: 4px; }
.right-5 { right: 5px; }
.right-6 { right: 6px; }
.right-7 { right: 7px; }
.right-8 { right: 8px; }
.right-9 { right: 9px; }
.right-10 { right: 10px; }
.right-11 { right: 11px; }
.right-12 { right: 12px; }
.right-13 { right: 13px; }
.right-14 { right: 14px; }
.right-15 { right: 15px; }

Found in Tailwind docs here:

From Tailwind docs:

https://www.youtube.com/watch?v=L2nyKwrEY8w
according to tailwind docs
https://tailwindcss.com/docs/installation/#2-add-tailwind-to-your-css
https://tailwindcss.com/docs/installation/#using-tailwind-with-postcss
https://tailwindcss.com/docs/installation/#3-create-your-tailwind-config-file-optional