Installation
Setting up Tailwind CSS in Ruby on Rails v7+ project.
Start by creating a new Rails project if you don't have one set up already. The most common approach is to use the Rails Command Line.
rails new my-projectcd my-project
Install the tailwindcss-ruby
and tailwindcss-rails
gems, and then run the install command to set up Tailwind CSS in your project.
./bin/bundle add tailwindcss-ruby -v 4.0.0.beta.9./bin/bundle add tailwindcss-rails./bin/rails tailwindcss:install
Add an @import
that imports Tailwind CSS to your application.tailwind.css
file located in the ./app/assets/stylesheets
directory.
@import "tailwindcss";
Run your build process with ./bin/dev
.
./bin/dev
Start using Tailwind's utility classes to style your content.
<h1 class="text-3xl font-bold underline"> Hello world!</h1>