I’m using Rails 8 with ActiveAdmin and trying to integrate Tailwind CSS in the admin interface. I created a custom SCSS file (active_admin.scss) inside app/assets/stylesheets/ but I’m facing the following issues:
ActiveAdmin does not load the SCSS file, even though it exists. I get an error stating "active_admin.css file does not exist" or similar message when the page is rendered. After generating an active_admin.css file, CSS is not loading properly, and only plain HTML is displayed on the page with no styles applied. Here’s what I have done so far:
I had a similar issue with activeadmin in Rails 8. I was able to solve it by using dartsass-rails.
bundle install
.bundle exec rails dartsass:install
config/initializers/dartsass.rb
and configure which .sass files should be build. I only added the active_admin.scss file:# config/initializers/dartsass.rb
Rails.application.config.dartsass.builds = {
'active_admin.scss' => 'active_admin.css'
}
Run bundle exec rails dartsass:build
Start your rails server and check http://127.0.0.1:3000/admin. Should be working now.
I have been testing this out a bit more but there seems to be more problems. While the CSS works, it looks like the javascript is not getting bundled because of the absence of sprockets. The delete button does not work and there is probably other stuff that I'm not aware of.
I also tried activeadmin v4.0.0.beta15 but the setup is a bit tricky since the standard procedure installs tailwindcss@4 but the gem uses v3. After following the upgrade guide I downgraded the tailwind version to v3 using yarn up tailwindcss@3
.
If you install tailwindcss@3 with yarn, it may be necessary to use node_modules and not Plug'n'Play (add nodeLinker: node-modules
to .yarnrc.yml
). This caused issues when running yarn build:css
since it would not find "@activeadmin/activeadmin/plugin".
In summary, it may be easier to just use Rails 7 for now. The activeadminv4 beta has been working fine and looks better than v3 if you want to try it out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With