Tailwind CSS with Rails asset pipeline

10722
0

Tailwind CSS provides utility-first styling that pairs perfectly with Rails component-driven architecture. I configure Tailwind to scan templates for class names and generate only the CSS being used. The standalone CLI runs during development with --watch to rebuild on file changes. For production, I run the build step during asset precompilation. Custom utilities, components, and theme values live in tailwind.config.js. I use @apply sparingly—mostly for third-party library overrides—preferring utility classes in templates for better visibility. The purge configuration ensures production bundles are tiny. Tailwind's design system constraints (spacing scale, color palette) enforce consistency without requiring strict style guides.