Does Tailwind Take Time?
- If you haven’t used Tailwind before, expect a slight learning curve (1-2 days) to get comfortable.
- But once you grasp utility classes, styling becomes faster than Bootstrap.
Fastest Way to Set Up Tailwind in Rails 8
1. Install Tailwind
rails new myapp --css=tailwind
Or, if you already have a Rails app:
โ bundle add tailwindcss-rails
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching tailwindcss-ruby 4.0.17 (arm64-darwin)
Installing tailwindcss-ruby 4.0.17 (arm64-darwin)
Fetching tailwindcss-rails 4.2.1
Installing tailwindcss-rails 4.2.1
โ rails tailwindcss:install
apply /Users/abhilash/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/tailwindcss-rails-4.2.1/lib/install/install_tailwindcss.rb
Add Tailwindcss container element in application layout
insert app/views/layouts/application.html.erb
insert app/views/layouts/application.html.erb
Build into app/assets/builds
create app/assets/builds
create app/assets/builds/.keep
append .gitignore
Add default /Users/xxxxx/rails/design_studio/app/assets/tailwind/application.css
create app/assets/tailwind/application.css
Add default Procfile.dev
create Procfile.dev
Ensure foreman is installed
run gem install foreman from "."
Fetching foreman-0.88.1.gem
Successfully installed foreman-0.88.1
Refer: https://tailwindcss.com/docs/installation/framework-guides/ruby-on-rails
Note: You can see this create a Procfile.dev file and installs foreman gem.
The foreman gem in Rails is used to manage and run multiple processes in development using a Procfile. It is particularly useful when your Rails application depends on several background services that need to run simultaneously.
Why is foreman used?
- It allows you to define and manage multiple services (like Rails server, Tailwind compiler, Sidekiq, etc.) in a single command.
- Ensures that all necessary processes start together, making development easier.
- Helps simulate production environments where multiple services need to run concurrently.
Who is using foreman? Rails or Tailwind CSS?
- The
foremangem itself is not specific to Rails or Tailwind CSSโit is a general-purpose process manager. - In our case, both Rails and Tailwind CSS are using
foreman.- Rails: You can use
foremanto start Rails server, background jobs, and Webpack. - Tailwind CSS: Since Tailwind needs a process to watch and compile CSS files (using
npx tailwindcss -i input.css -o output.css --watch),foremanhelps keep this process running.
- Rails: You can use
What is Procfile.dev in Tailwind CSS?
- When you install Tailwind in Rails, a
Procfile.devis created to define the processes required for development. - Example
Procfile.devfor Tailwind and Rails:web: bin/rails server -p 3000js: yarn build --watchcss: bin/rails tailwindcss:watchweb: Starts the Rails server.js: Watches and compiles JavaScript files (if using esbuild or webpack).css: Watches and compiles Tailwind CSS files.
How to use foreman?
- Run the following command to start all processes defined in
Procfile.dev:bin/dev- This starts the Rails server, the Tailwind CSS watcher, and other necessary processes.
The foreman gem is used as a process manager to run multiple services in development. In our case, both Rails and Tailwind CSS are using it. It ensures that Tailwindโs CSS compilation process runs alongside the Rails server.
2. Use Tailwind Classes in Views
Example:
<div class="container mx-auto p-4">
<h1 class="text-blue-500 text-3xl font-bold">Welcome to My App</h1>
<button class="bg-green-500 text-white px-4 py-2 rounded">Click Me</button>
</div>
This keeps your CSS minimal, avoids custom stylesheets, and helps you learn Tailwind naturally while building your app.
Here’s a Tailwind CSS Cheat Sheet to help you get started quickly with your Rails 8 app.
๐ 1. Layout & Spacing
<div class="container mx-auto p-4">
<div class="m-4 p-4 bg-gray-200">Margin & Padding</div>
</div>
mx-autoโ Center content horizontallyp-4โ Padding (4 * 4px = 16px)m-4โ Margin (4 * 4px = 16px)
๐จ 2. Colors
<div class="bg-blue-500 text-white p-4">Blue Background</div>
<div class="text-red-600">Red Text</div>
- Colors:
gray,red,blue,green, etc. - Shades:
100 - 900(lighter โ darker)
Refer: https://tailwindcss.com/docs/background-color
๐ค 3. Typography
<p class="text-lg font-bold">Large Bold Text</p>
<p class="text-sm italic">Small Italic Text</p>
text-lgโ Large texttext-smโ Small textfont-boldโ Bold textitalicโ Italic text
๐ 4. Width & Height
<div class="w-1/2 h-32 bg-green-300">50% Width, 128px Height</div>
w-1/2โ 50% widthw-fullโ Full widthh-32โ 128px height
๐ณ 5. Flexbox & Grid
<div class="flex justify-center items-center h-screen">
<div class="bg-blue-500 p-4 text-white">Centered Box</div>
</div>
flexโ Enables flexboxjustify-centerโ Centers horizontallyitems-centerโ Centers vertically
๐ 6. Buttons
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Click Me
</button>
hover:bg-blue-700โ Darker blue on hoverroundedโ Rounded corners
๐ 7. Borders & Shadows
<div class="border border-gray-400 shadow-lg p-4">Border & Shadow</div>
borderโ Default borderborder-gray-400โ Gray bordershadow-lgโ Large shadow
๐ฒ 8. Responsive Design
<div class="p-4 text-sm md:text-lg lg:text-xl">
Text size changes on different screens!
</div>
sm:โ Small screens (โฅ 640px)md:โ Medium screens (โฅ 768px)lg:โ Large screens (โฅ 1024px)
โจ 9. Animations & Transitions
<button class="bg-green-500 transition duration-300 hover:bg-green-700">
Smooth Transition
</button>
transitionโ Enables animationsduration-300โ 300ms transition speedhover:bg-green-700โ Change color on hover
๐ Quick Setup for Your Rails 8 App
- Install Tailwind
rails new myapp --css=tailwind
- Use Tailwind Classes in Views
<div class="text-center p-6 text-2xl text-blue-500">Hello Tailwind!</div>
๐ฅ Bonus: Try Tailwind Play for live previews!
Tailwind in design studio
Check our Rails 8 app for tailwind implementation: https://github.com/abhilashak/design_studio/blob/main/bin/dev
I have added Tailwind CSS to our design_studio app. You can check the commit here: https://github.com/abhilashak/design_studio/commit/07db459

Track our Github Issue for tailwind task: https://github.com/abhilashak/design_studio/issues/1
The above issue will be automatically closed if you follow our Git commit message principle, that is mentioned in the below post:
Finally add the Tailwind Plugin Tailwind CSS IntelliSense for VS Code to make development easy.

to be continued.. ๐