[Bug/Regression] Dynamic panel colors not automatically injected in custom theme CSS with Tailwind 4
In Filament v3 with Tailwind v3, dynamic panel colors (defined via ->colors() or tenant-specific colors via middleware) were automatically available in custom theme CSS files without any additional setup.
With Filament v4 + Tailwind v4, these dynamic colors are no longer automatically available when using utility classes like text-primary-500, bg-primary-50, etc. in custom theme CSS files.
Expected Behavior (Filament v3)
Setup:
The classes would automatically use the dynamic colors defined in the panel provider.
Actual Behavior (Filament v4)
The same code doesn't work. The utility classes text-primary-500, bg-primary-50, etc. don't reflect the dynamic colors.
Root Cause
Tailwind v4 requires explicit color declarations via @theme inline directive
Filament v4 doesn't automatically inject CSS variables (--primary-500, --primary-600, etc.) into the DOM when colors are set via ->colors() or middleware
Developers must manually create a render hook to inject these variables
Current Workaround
Developers must add a HEAD_END render hook and a Blade view to inject CSS variables:
1. Add render hook:
2 Replies
2. Create Blade view:
3. Add Tailwind v4 theme declaration:
Proposed Solution
Filament v4 should automatically inject CSS variables for panel colors into the <head> when a custom theme is used, similar to how it worked in v3.
Suggested implementation:
Automatically inject color CSS variables when viteTheme() is used
Include a <style> tag in the panel layout that generates CSS variables from $panel->getColors()
Provide a config option to disable this behavior for advanced use cases
Example implementation in PanelManager or similar:
Benefits
✅ Backward compatibility - Existing v3 theme CSS would work with minimal changes
✅ Better DX - No need for manual boilerplate code
✅ Consistency - Works the same way across Filament installations
✅ Multi-tenancy friendly - Works automatically with dynamic tenant colors
Additional Context
This issue particularly affects:
Multi-tenant applications with per-tenant branding
Applications migrating from Filament v3 to v4
Custom admin themes that override default Filament styles
The workaround is functional but requires significant boilerplate that should ideally be handled by the framework itself.
I get the colors injected without additional setup:
