Skip to content

Theme switcher

The theme switcher adds a swatch button to the topbar that opens a slide-over aside where signed-in users pick a theme, brand colors, and navigation overrides. It is off by default.

use Coolsam\FilamentChrome\Themes\MidnightGlassTheme;
use Coolsam\FilamentChrome\Themes\SoftFloatingTheme;
use Coolsam\FilamentChrome\Themes\SoftNeumorphicTheme;
FilamentChromePlugin::make()
->theme(SoftFloatingTheme::make())
->themeSwitcher([
SoftFloatingTheme::class, // label: "Soft Floating"
MidnightGlassTheme::class => 'Midnight Glass', // custom label (string or Htmlable)
SoftNeumorphicTheme::make(), // instance (customised themes)
]);
->themeSwitcher() // every bundled theme (ThemeSwitcher::BUNDLED_THEMES)
->themeSwitcher(false) // disable (default)

The array may mix three shapes:

  • Class string — the label is the title-cased theme id(), so soft-floating becomes Soft Floating.
  • Class-keyed map — [MidnightGlassTheme::class => 'Midnight Glass']; the label may be a string or an Htmlable (shown as its text content).
  • Theme instance — for themes you configured or wrote yourself.

Every entry must implement ChromeTheme. An empty array throws — pass false to disable.

ThemeSwitcher::BUNDLED_THEMES (Coolsam\FilamentChrome\Support\ThemeSwitcher) lists all ten bundled theme classes.

Default theme: the panel’s ->theme() when the switcher offers it, otherwise the first theme in the array.

The trigger renders at PanelsRenderHook::GLOBAL_SEARCH_AFTER — inside the topbar end cluster, before notifications and the user menu. Move it with any panel render hook:

use Filament\View\PanelsRenderHook;
->themeSwitcherRenderHook(PanelsRenderHook::USER_MENU_BEFORE)

The aside itself (a Livewire component with a Filament slide-over action) mounts at BODY_END, so themed topbars with transforms or backdrop filters cannot trap the modal. Both render only for authenticated users.

  • A radio list of the offered themes with palette swatches.
  • Four optional color pickers: light primary and accent, dark primary and accent.
  • Optional navigation overrides: navigation type (Side / Top / App / App Inverse), side-nav mode (Accordion / Static), and treeline (show / hide).

Empty colors and Theme default navigation options fall back to the plugin config (->primary(), ->accent(), ->darkPrimary(), ->darkAccent(), ->navigationType(), ->sideNavMode(), ->treeline()), then the active theme’s tokens and layout defaults.

Apply on close: dismissing the aside (close button, backdrop click, Escape) saves the form exactly like Apply, then reloads the page so the theme stylesheet, body attributes and navigation layout re-render. Apply remains as an explicit apply-and-close.

Reset to defaults clears the stored overrides (theme, colors, navigation type, side-nav mode, treeline) so theme and panel defaults apply again.

Choices are stored per panel:

  • in the session under filament-chrome.theme-switcher.{panel}, and
  • in a one-year cookie filament_chrome_theme_{panel}, encrypted by the panel’s EncryptCookies middleware, which restores the choice after the session expires.

Unknown theme ids and malformed colors are ignored.

  • The body data-fi-chrome-theme attribute and theme class.
  • The theme stylesheet — every offered theme’s pack is registered, only the active one is linked.
  • Google fonts and the panel font family.
  • The theme’s layout defaults (defaultNavigationType(), defaultSideNavMode(), defaultTreeline()).
  • Colors, applied as :root --primary-* and .dark --primary-* / --accent-* overrides after Filament’s own color variables.

Switcher navigation overrides win over explicit plugin config.

UI strings live under filament-chrome::theme-switcher.*. Publish and edit the package translations to localize labels such as heading (“Appearance”), apply and reset.