PHP code example of andreia / filament-ui-switcher
1. Go to this page and download the library: Download andreia/filament-ui-switcher library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andreia / filament-ui-switcher example snippets
'defaults' => [
'font' => 'Inter', // Default font family
'color' => '#6366f1', // Default primary color
'layout' => 'sidebar', // Default layout
'font_size' => 16, // Default font size in pixels
'density' => 'default', // Default UI density
],
'fonts' => [
'Inter',
'Poppins',
'Public Sans',
'DM Sans',
'Nunito Sans',
'Roboto',
// Add any Google Font you want:
// 'Montserrat',
// 'Open Sans',
],
'font_size_range' => [
'min' => 12, // Minimum font size in pixels
'max' => 20, // Maximum font size in pixels
],
'layouts' => [
'sidebar', // Full sidebar with icons and labels
'sidebar-collapsed', // Collapsed sidebar (icons only)
'sidebar-no-topbar', // Sidebar without topbar (Filament v4.1+)
'topbar', // Top navigation bar
],
use Andreia\FilamentUiSwitcher\FilamentUiSwitcherPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->id('admin')
->path('admin')
// ... other config
->plugin(FilamentUiSwitcherPlugin::make());
}
use Andreia\FilamentUiSwitcher\FilamentUiSwitcherPlugin;
use Filament\View\PanelsRenderHook;
->plugin(
FilamentUiSwitcherPlugin::make()
->iconRenderHook(PanelsRenderHook::TOPBAR_END)
)
return [
/*
|--------------------------------------------------------------------------
| Storage Driver
|--------------------------------------------------------------------------
| Where to store UI preferences.
| Options: 'session' (default), 'database'
*/
'driver' => 'session',
/*
|--------------------------------------------------------------------------
| Database Column
|--------------------------------------------------------------------------
| Only used if driver = 'database'.
| The column on the users table where preferences are stored as JSON.
*/
'database_column' => 'ui_preferences',
];
use Andreia\FilamentUiSwitcher\Models\Traits\HasUiPreferences;
class User extends Authenticatable
{
use HasUiPreferences;
protected function casts(): array
{
return [
// ...
'ui_preferences' => 'array',
];
}
}
'driver' => 'database',
use Andreia\FilamentUiSwitcher\Support\UiPreferenceManager;
// Get a preference
$font = UiPreferenceManager::get('ui.font', 'Inter');
// Set a preference
UiPreferenceManager::set('ui.color', '#10b981');
// Get user's preference
$font = auth()->user()->getUiPreference('ui.font', 'Inter');
// Set user's preference
auth()->user()->setUiPreference('ui.color', '#10b981');