Problem

Stack

  • Rails 7.0
  • View Components
  • Tailwind

CSS classes that were used only in a View Component, Tailwind would not include them during the build.

Elements had the correct classes applied in the UI but there were no compiled styles.

Solution

Update the tailwind.config.js file to include the files in app/components and restart the server 🎉

module.exports = {  
  content: [  
+	'./app/components/**/*.rb',  
+   './app/components/**/*.html.erb',
    './app/views/**/*.html.erb',    
    './app/helpers/**/*.rb',  
    './app/assets/stylesheets/**/*.css',  
    './app/javascript/**/*.js'  
  ],  
  ...
}