colors

#❓┊help How can i take the colors for a panel based on the logged in user
2 Replies
Patrick Boivin
I think you can do this in a service provider (e.g. AppServiceProvider):
public function boot(): void
{
Filament::serving(function () {
$color = auth()->user()->getColor(); // e.g. 'Blue'

FilamentColor::register(['primary' => constant('\Filament\Support\Colors\Color::' . $color)]);
});
}
public function boot(): void
{
Filament::serving(function () {
$color = auth()->user()->getColor(); // e.g. 'Blue'

FilamentColor::register(['primary' => constant('\Filament\Support\Colors\Color::' . $color)]);
});
}
awcodes
awcodes2y ago
Or if it's a hex color stored in the DB.
FilamentColor::register([
'primary' => Color::hex($color)
])
FilamentColor::register([
'primary' => Color::hex($color)
])

Did you find this page helpful?