DEV3 Technologies home

Filament custom panel theme with neutral palette

Brand a Filament 4 panel with a custom Tailwind theme stylesheet, a neutral colour palette, a web font, a logo name and dark mode defaults.

FilamentThemingfilamentthemetailwindbranding

Code

<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Support\Enums\Width;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('admin')
            ->path('admin')
            ->login()
            ->brandName('Acme Console')
            ->font('Inter')                      // loaded from the font provider, no CSS needed
            ->maxContentWidth(Width::SevenExtraLarge)
            ->sidebarCollapsibleOnDesktop()
            ->colors([
                // A custom 50-950 scale: calm blue-grey, no strong hue.
                'primary' => [
                    50 => 'oklch(0.97 0.006 250)',
                    100 => 'oklch(0.93 0.01 250)',
                    200 => 'oklch(0.87 0.015 250)',
                    300 => 'oklch(0.78 0.02 250)',
                    400 => 'oklch(0.66 0.025 250)',
                    500 => 'oklch(0.55 0.03 250)',
                    600 => 'oklch(0.47 0.03 250)',
                    700 => 'oklch(0.40 0.028 250)',
                    800 => 'oklch(0.32 0.022 250)',
                    900 => 'oklch(0.25 0.018 250)',
                    950 => 'oklch(0.18 0.012 250)',
                ],
                'gray' => Color::Zinc,
                'success' => Color::Emerald,
                'danger' => Color::Rose,
            ])
            // Compiled by Vite from the stylesheet below.
            ->viteTheme('resources/css/filament/admin/theme.css');
    }
}

Needs: filament/filament@^4.0

How it works

What it solves

The default Filament look is good, but a product panel often needs its own colour scale, typeface and component feel. This snippet shows the supported way to do that in Filament 4: panel-level options for the big things and a compiled theme stylesheet for fine detail.

How it works

The provider covers everything that does not need CSS. brandName() sets the sidebar title, font() loads a web font, maxContentWidth() widens the content area and sidebarCollapsibleOnDesktop() lets users reclaim space. colors() receives a complete 50-950 scale for the primary colour written in oklch, a calm blue-grey with almost no chroma, plus named palettes for gray, success and danger. Filament derives hover, focus and badge colours from that scale.

viteTheme() points to a stylesheet that you compile with Vite. The file imports Filament's own theme, declares @source paths so Tailwind 4 scans your PHP and Blade files, overrides radius tokens through @theme, and tweaks a few fi-* component classes: the sidebar divider, flat bordered sections and compact table headers. Dark mode is handled with the .dark variant on the same selectors.

Adapting it

Replace the hue number (250) with another angle to retint the whole scale, or use one of the built-in Color:: constants. Keep contrast in mind: shade 600 should read well with white text on buttons.

Pitfalls

  • Add the CSS file to vite.config.js inputs and run npm run build, otherwise the page loses its styles.
  • fi-* class names can change between releases, so keep overrides few.
  • Test every tweak in both light and dark mode.

How to use it

  1. Create the theme: php artisan make:filament-theme admin (it prepares the folder), then replace its CSS with this file.
  2. Add resources/css/filament/admin/theme.css to the input array in vite.config.js.
  3. Put the provider options into your panel and run npm run build.
  4. Change the oklch hue number to retint the scale.
  5. Check both light and dark mode, plus buttons, badges and charts.

Licence: DEV3 Snippet Licence. Free to use, change and ship in personal and commercial projects. Attribution is appreciated, not required. Please do not redistribute snippets as a collection.

Related snippets