notwonderful/filament-moonlight-theme
Installation
Run composer require notwonderful/filament-moonlight-theme in your project root.
Ensure your project uses Filament 4.0+ and PHP 8.1+.
Register the Plugin
Add the plugin to your Panel provider (e.g., app/Providers/Filament/AdminPanelProvider.php):
use notwonderful\FilamentMoonlightTheme\MoonlightTheme;
public function panel(Panel $panel): Panel {
return $panel
->plugin(MoonlightTheme::make());
}
Publish & Build Assets
Run php artisan filament:assets to compile the theme’s CSS/JS.
The theme only activates in dark mode (browser/system preference or manual toggle).
Verify Open your Filament panel in dark mode—colors should now reflect the Moonlight palette (soft blues, grays, and purples).
Consistent Dark Theme
PanelServiceProvider if managing multiple panels.Customization Hooks
php artisan vendor:publish --tag="filament-moonlight-theme-assets"
Modify the published CSS file (e.g., resources/css/filament/moonlight.css) to tweak colors or add variables.register method:
MoonlightTheme::make()
->canAccess(fn () => Auth::user()->prefers_dark_mode)
Integration with Filament Features
Testing
Dynamic Theme Switching
public function panel(Panel $panel): Panel {
return $panel
->plugin(
request()->user()->prefers_dark_mode
? MoonlightTheme::make()
: new LightThemePlugin()
);
}
Theme for Specific Resources/Pages
plugin method in resource classes to scope the theme:
public static function getPlugins(): array {
return [
MoonlightTheme::make(),
];
}
CI/CD Considerations
filament:assets runs in your deployment pipeline (e.g., Laravel Forge/Envoyer) to avoid broken assets.Asset Compilation
filament:assets after installation will leave the theme unstyled.post-install-cmd in composer.json:
"scripts": {
"post-install-cmd": [
"@php artisan filament:assets"
]
}
Dark Mode Detection
Settings or a custom widget:
use notwonderful\FilamentMoonlightTheme\Facades\MoonlightTheme;
// Toggle via a button click
MoonlightTheme::toggle();
CSS Conflicts
/* Only apply in light mode */
@media (prefers-color-scheme: light) {
.custom-class { ... }
}
Filament Version Mismatch
composer.json if needed:
"notwonderful/filament-moonlight-theme": "1.0.0"
Inspect Elements
F12) to verify the theme’s CSS classes (e.g., .filament-moonlight) are loaded.body tag for data-dark attributes if dark mode isn’t triggering.Asset Paths
resources/css/filament/moonlight.css
public/build/filament/css/filament.css
Clear Caches
php artisan cache:clear
php artisan view:clear
php artisan filament:assets
Custom Color Palette
MoonlightTheme::make()
->colors([
'primary' => '#6c5ce7', // Custom primary color
]);
Add Theme to Filament Settings
Settings page:
use Filament\Settings\SettingsWidget;
public static function getSettingsWidgets(): array {
return [
MoonlightTheme::makeSettingsWidget(),
];
}
Localization
php artisan vendor:publish --tag="filament-moonlight-theme-translations"
Performance
MoonlightTheme::make()
->lazyLoad();
Accessibility
prefers-reduced-motion media query to disable animations if needed.Community
How can I help you explore Laravel packages today?