irajul/filament-shadcn-theme
Installation:
composer require irajul/filament-shadcn-theme
php artisan vendor:publish --tag=filament-shadcn-theme-config
This auto-discovers the package and publishes the config file.
Register the Plugin:
Add the plugin to your PanelProvider (e.g., AdminPanelProvider):
use Irajul\FilamentShadcnTheme\FilamentShadcnThemePlugin;
public function panel(Panel $panel): Panel {
return $panel->plugin(FilamentShadcnThemePlugin::make());
}
First Use Case:
Apply a theme preset (e.g., Lyra style with Taupe colors):
->plugin(FilamentShadcnThemePlugin::make()
->style(StyleVariant::Lyra)
->baseColor(BaseColor::Taupe)
->themeColor(ThemeColor::Taupe)
)
Refresh your Filament panel to see the theme applied.
config/filament-shadcn-theme.php for global defaults.Enums/ directory for available options (e.g., StyleVariant, BaseColor).Panel-Specific Theming:
Override defaults in the PanelProvider for each Filament panel:
->plugin(FilamentShadcnThemePlugin::make()
->style(StyleVariant::Nova)
->font('geist')
)
Dark/Light Mode Sync:
Use Filament’s ThemeMode with the plugin’s darkMode() helper:
->defaultThemeMode(ThemeMode::Dark)
->plugin(FilamentShadcnThemePlugin::make()->darkMode(true))
Production Optimization:
Switch to cached-asset mode for performance:
->plugin(FilamentShadcnThemePlugin::make()->cssMode(CssMode::CachedAsset))
Warm the cache after deployment:
php artisan filament-shadcn-theme:cache --panel=admin
Custom Fonts: Use built-in fonts or custom strings:
->font('inter') // Built-in
->headingFont('Custom Font, sans-serif') // Custom
Token Overrides: Fine-tune shadcn tokens directly (e.g., for accessibility):
->tokens(
light: ['background' => 'oklch(1 0 0)'],
dark: ['background' => 'oklch(0.16 0.01 90)']
)
Selector Mapping: Target custom Filament classes (e.g., from plugins):
->selectorMap([
'card' => '.fi-section, .custom-card-class',
])
filament-shadcn-theme:clear to reset cached assets during tests:
php artisan filament-shadcn-theme:clear --panel=admin
CSS Conflicts:
cached-asset mode for isolation or scope selectors tightly (e.g., .filament-shadcn-*).Font Loading:
@font-face rules to your app’s CSS or use a CDN (e.g., Google Fonts).Dark Mode Mismatch:
ThemeMode and the plugin’s darkMode() may desync.->defaultThemeMode(ThemeMode::Dark)
->plugin(FilamentShadcnThemePlugin::make()->darkMode(true))
Cached Asset Permissions:
cached-asset mode fails if public/vendor/ is unwritable.storage/framework/ (requires config override).Selector Specificity:
selectorMap (e.g., target .fi-* classes).--fs-primary).filament-shadcn-theme:clear if changes don’t apply.dd(FilamentShadcnThemePlugin::make()->getConfig());
Dynamic Themes: Load configurations from a database or API:
$theme = Theme::find($id);
->plugin(FilamentShadcnThemePlugin::make()
->style($theme->style)
->themeColor($theme->color)
)
User Preferences: Store theme preferences in the user model and apply them via middleware:
// Middleware
$user->theme->applyTo(FilamentShadcnThemePlugin::make());
Custom Tokens:
Extend the package by publishing and overriding the tokens() method in a child class:
class CustomShadcnThemePlugin extends FilamentShadcnThemePlugin {
public function tokens(): array {
return array_merge(parent::tokens(), [
'light' => ['--custom-token' => 'value'],
]);
}
}
StyleVariant::Lyra) or strings (e.g., 'lyra').$this->filament->plugin(FilamentShadcnThemePlugin::make()->style('nova'));
How can I help you explore Laravel packages today?