Custom themes
A theme is any class implementing Coolsam\FilamentChrome\Themes\ChromeTheme. The
HasChromeThemeHooks trait provides empty defaults for every hook, so you only override
what you need.
use Coolsam\FilamentChrome\Themes\ChromeTheme;use Coolsam\FilamentChrome\Themes\Concerns\HasChromeThemeHooks;
class MidnightTheme implements ChromeTheme{ use HasChromeThemeHooks;
public static function make(): static { return new static; }
public function id(): string { return 'midnight'; }
public function base(): string { return 'dark'; // tokens describe html.dark; invent a light twin in CSS }
public function extraCss(): string { return <<<'CSS'html.dark body.fi-chrome-theme-midnight .fi-sidebar { background: #0b1220; }html:not(.dark) body.fi-chrome-theme-midnight .fi-sidebar { background: #f4f6fb; }CSS; }}FilamentChromePlugin::make()->theme(MidnightTheme::make());Contract
Section titled “Contract”| Method | Returns | Purpose |
|---|---|---|
id() |
string |
Short unique name. |
base() |
'dark'|'light'|'both' |
Which Filament mode the design tokens describe. Trait default: both. |
fontFamily() |
?string |
CSS font stack for the panel body. Trait default: tokens()['font']. |
googleFonts() |
array<int, string> |
Google font family names to load (e.g. ['Poppins']). |
stylesheet() |
?string |
A bundled pack name (e.g. shamar.css), a public URL (https://…) or an absolute path (/css/my-theme.css). |
extraCss() |
string |
CSS injected after the theme stylesheet. |
sidebar(), topbar(), brand() |
string |
Extra classes for those chrome slots. |
navigation(), navigationItem(), navigationItemActive() |
string |
Extra classes for nav roots, items and the active leaf. |
navigationGroup(), navigationGroupActive() |
string |
Extra classes for groups and the group containing the open page. |
content(), sidebarFoot(), auth(), authCard() |
string |
Extra classes for main content, sidebar footer, guest auth document and auth card. |
tokens() |
array |
Optional palette / size tokens: primary, accent, surface, heading, font, radius, sidebarWidth, topbarHeight, bodyBackground, darkPrimary, darkSurface, darkHeading. |
defaultNavigationType() |
?NavigationType |
Preferred layout (null = no preference). |
defaultSideNavMode() |
?SideNavMode |
Preferred side-nav mode. |
defaultTreeline() |
?bool |
Preferred treeline visibility. |
A theme’s tokens()['primary'] feeds the panel’s primary color scale when the plugin does
not set ->primary(), and tokens()['accent'] becomes --fi-chrome-accent.
Light / dark authoring
Section titled “Light / dark authoring”When translating a design spec (for example a JSON token file with "base": "dark"):
- Map the spec’s
basetobase():'dark','light', or'both'. - Scope those tokens with Filament’s
html.dark/html:not(.dark)selectors. - Invent a coherent twin for the opposite mode — don’t leave unthemed chrome.
- Dual flat shells (like Shamar and Harbor) use
base(): 'both'and style both modes on purpose. - Plugin
->primary()/->accent()still win over theme fallbacks.
Selectors for theme CSS
Section titled “Selectors for theme CSS”On chrome panels the plugin adds fi-chrome and fi-chrome-theme-{id} classes to <body>
and mirrors these attributes onto <html> and <body>:
| Attribute | Values |
|---|---|
data-fi-chrome-theme |
Active theme id() |
data-fi-chrome-theme-base |
dark, light or both |
data-fi-chrome-nav |
side, top, app or inverse |
data-fi-chrome-side-nav-mode |
accordion or static |
data-fi-chrome-sidebar-offcanvas |
true or false |
data-fi-chrome-treeline |
true or false (also the fi-chrome-nav--treeline class) |
Scope theme rules to body.fi-chrome-theme-{id} and Filament’s html.dark /
html:not(.dark) so they never leak into other panels or modes.
Reusing a bundled pack
Section titled “Reusing a bundled pack”A custom theme can extend a bundled look by returning its pack from stylesheet(), e.g.
return 'soft-floating.css';. The plugin registers it under your theme’s id so it is
linked only when your theme is active.