Version

Theme

Core Concepts

Colors

Overview

Filament uses CSS variables to define its color palette. These CSS variables are mapped to Tailwind classes in the preset file that you load when installing Filament.

Customizing the default colors

From a service provider's boot() method, or middleware, you can call the FilamentColor::register() method, which you can use to customize which colors Filament uses for UI elements.

There are 6 default colors that are used throughout Filament that you are able to customize:

use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
 
FilamentColor::register([
'danger' => Color::Red,
'gray' => Color::Zinc,
'info' => Color::Blue,
'primary' => Color::Amber,
'success' => Color::Green,
'warning' => Color::Amber,
]);

The Color class contains every Tailwind CSS color to choose from.

You can also pass in a function to register() which will only get called when the app is getting rendered. This is useful if you are calling register() from a service provider, and want to access objects like the currently authenticated user, which are initialized later in middleware.

Using a non-Tailwind color

You can use custom colors that are not included in the Tailwind CSS color palette by passing an array of color shades from 50 to 950 in RGB format:

use Filament\Support\Facades\FilamentColor;
 
FilamentColor::register([
'danger' => [
50 => '254, 242, 242',
100 => '254, 226, 226',
200 => '254, 202, 202',
300 => '252, 165, 165',
400 => '248, 113, 113',
500 => '239, 68, 68',
600 => '220, 38, 38',
700 => '185, 28, 28',
800 => '153, 27, 27',
900 => '127, 29, 29',
950 => '69, 10, 10',
],
]);

Generating a custom color from a hex code

You can use the Color::hex() method to generate a custom color palette from a hex code:

use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
 
FilamentColor::register([
'danger' => Color::hex('#ff0000'),
]);

Generating a custom color from an RGB value

You can use the Color::rgb() method to generate a custom color palette from an RGB value:

use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
 
FilamentColor::register([
'danger' => Color::rgb('rgb(255, 0, 0)'),
]);

Registering extra colors

You can register extra colors that you can use throughout Filament:

use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;
 
FilamentColor::register([
'indigo' => Color::Indigo,
]);

Now, you can use this color anywhere you would normally add primary, danger, etc.

Edit on GitHub

Still need help? Join our Discord community or open a GitHub discussion

Previous
Icons