How It Works
When you install Spree Admin, the installer creates a file atapp/assets/tailwind/spree_admin.css in your application. This file:
- Imports the base Spree Admin styles from the gem
- Scans your custom admin views, helpers, and JavaScript for Tailwind classes
- Allows you to add custom styles and override theme variables
Using Tailwind Utility Classes
You can use any Tailwind CSS utility class in your custom admin views, helpers, or JavaScript files. The build process automatically scans these locations:app/views/spree/admin/**/*.erbapp/helpers/spree/admin/**/*.rbapp/javascript/spree/admin/**/*.js
Customizing the Theme
Overriding Theme Colors
To override Tailwind theme values, add a@theme block in your app/assets/tailwind/spree_admin.css file after the import:
app/assets/tailwind/spree_admin.css
Available Theme Variables
The Spree Admin theme defines these customizable variables:| Variable | Default | Description |
|---|---|---|
--color-primary | var(--color-zinc-950) | Primary brand color |
--color-success | var(--color-green-900) | Success state color |
--color-danger | var(--color-red-600) | Error/danger state color |
--color-warning | var(--color-yellow-900) | Warning state color |
--color-info | var(--color-blue-900) | Info state color |
Overriding Layout Variables
You can also customize layout-related CSS variables:app/assets/tailwind/spree_admin.css
Adding Custom Components
Use Tailwind’s@layer directive to add custom component styles that work seamlessly with the existing design:
app/assets/tailwind/spree_admin.css
Adding Custom Utilities
For reusable utility classes, use the utilities layer:app/assets/tailwind/spree_admin.css
Scanning Additional Paths
If you have admin-related code in non-standard locations, add additional@source directives:
app/assets/tailwind/spree_admin.css
Development Workflow
Starting the CSS Watcher
During development, run the Tailwind CSS watcher to automatically rebuild styles when you make changes:Procfile.dev with foreman:
- Your host app’s CSS files in
app/assets/tailwind/ - The Spree Admin engine’s CSS files
- All files matching your
@sourcepatterns
Building for Production
CSS is automatically compiled during asset precompilation:Common Customization Examples
Custom Primary Color Scheme
app/assets/tailwind/spree_admin.css
Dark Mode Adjustments
app/assets/tailwind/spree_admin.css
Custom Form Styling
app/assets/tailwind/spree_admin.css
Troubleshooting
Changes Not Appearing
- Ensure the watcher is running:
bin/rails spree:admin:tailwindcss:watch - Check that your files are in paths covered by
@sourcedirectives - Hard refresh the browser (Cmd+Shift+R or Ctrl+Shift+R)
Missing Utility Classes
If a Tailwind class isn’t working, ensure:- The class is used in a file that’s scanned by
@source - The class name is complete (not dynamically constructed)
- Run a fresh build:
bin/rails spree:admin:tailwindcss:build
Listen Gem Required
The watch task requires thelisten gem. Add it to your Gemfile:
Gemfile

