Installation
composer require andreia/filament-ui-switcher
Publish the config file:
php artisan vendor:publish --provider="Andreia\FilamentUISwitcher\FilamentUISwitcherServiceProvider" --tag="config"
Register the Plugin
Add to app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\Andreia\FilamentUISwitcher\FilamentUISwitcherPlugin::make(),
]);
}
First Use Case Access the UI switcher via the ⚙️ icon in the Filament topbar. Test session-based storage by toggling options and refreshing the page.
Customizing UI Globally
Modify config/filament-ui-switcher.php to:
primary_colors), fonts (font_families), or font sizes.mode_switcher_enabled).Database Storage Integration
Extend the User model to include UI preferences:
use Andreia\FilamentUISwitcher\Traits\HasUISwitcherPreferences;
class User extends Authenticatable
{
use HasUISwitcherPreferences;
}
Update the config to use database storage:
'storage' => 'database',
Dynamic Layout Switching
Use the FilamentUISwitcher facade to programmatically apply settings:
use Andreia\FilamentUISwitcher\Facades\FilamentUISwitcher;
FilamentUISwitcher::setPrimaryColor('#3b82f6');
FilamentUISwitcher::setFontFamily('Inter');
Conditional Plugin Rendering Disable the plugin for specific users/roles in the panel provider:
->plugins([
FilamentUISwitcherPlugin::make()->visible(fn () => auth()->user()->isAdmin()),
])
Caching Conflicts Clear Filament and view caches after changing config:
php artisan filament:cache:clear
php artisan view:clear
Database Storage Quirks
ui_preferences table exists (migration runs automatically).database storage, verify the user_id column in the table matches your users table.Livewire Version Mismatch The plugin requires Livewire 3.x or 4.x. If using Filament 4.1+, ensure compatibility:
composer require livewire/livewire:^3.0
Console Logs: Enable debug mode in config:
'debug' => env('APP_DEBUG', false),
Check logs for storage-related errors.
Modal Not Appearing?
Verify the plugin is registered in AdminPanelProvider and the ⚙️ icon is visible in the topbar.
Custom Colors/Fonts Extend the config arrays to add your own options:
'primary_colors' => [
'#3b82f6', // Default blue
'#10b981', // Custom green
'#8b5cf6', // Custom purple
],
Override Default Views Publish and modify the Blade views:
php artisan vendor:publish --tag="filament-ui-switcher-views"
API Integration Use the facade to fetch/sync settings via API:
$preferences = FilamentUISwitcher::getPreferences();
FilamentUISwitcher::setPreferences($newPrefs);
How can I help you explore Laravel packages today?