PHP code example of nrep / filament-theme-switcher
1. Go to this page and download the library: Download nrep/filament-theme-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/ */
nrep / filament-theme-switcher example snippets
use Isura\FilamentThemeSwitcher\FilamentThemeSwitcherPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ... other configuration
->plugin(
FilamentThemeSwitcherPlugin::make()
);
}
use Isura\FilamentThemeSwitcher\Http\Middleware\SetTheme;
public function panel(Panel $panel): Panel
{
return $panel
// ... other configuration
->middleware([
// ... other middleware
SetTheme::class,
]);
}
// config/filament-theme-switcher.php
return [
'mode' => 'global', // or 'user' for per-user themes
'default_theme' => 'default',
];
use Filament\View\PanelsRenderHook;
use Illuminate\Support\Facades\Blade;
public function panel(Panel $panel): Panel
{
return $panel
->renderHook(
PanelsRenderHook::USER_MENU_BEFORE,
fn () => Blade::render('@livewire(\'theme-switcher\')')
);
}