Logo

dev-resources.site

for different kinds of informations.

Change Default Colors in FilamentPHP

Published at
6/30/2024
Categories
php
laravel
filament
tailwindcss
Author
arielmejiadev
Categories
4 categories in total
php
open
laravel
open
filament
open
tailwindcss
open
Author
13 person written this
arielmejiadev
open
Change Default Colors in FilamentPHP

Set Colors for a single Resources

Using filament we are able to define the colors for all the resources in the AppPanelProvider.php class, this class is typically the one that is created by default in a filament project installation command, we can define a lot of features in this case we are going to set the colors for the whole resources:

public function panel(Panel $panel): Panel
{
    return $panel
        ->default()
        ->id('app')
        ->path('/')
        ->login()
        ->colors([
            'primary' => Color::Slate,
            'gray' => Color::Gray
        ]);
}
Enter fullscreen mode Exit fullscreen mode

Now all the genereated resources are going to use this colors, take in mind that the value of the colors is handle by a Color class provided by Filament in the namespace namespace Filament\Support\Colors and it provides an identifier for all the colors in the TailwindCSS color pallete.

Set colors in a custom action

You can define custom actions using vainilla livewire components, in this cases you would need to explicitly define the color by chaining the colors method:

->color(Color::Slate)
Enter fullscreen mode Exit fullscreen mode

Set Colors Globally

From a service provider's boot() method you can define the colors for your app globally:

public function boot(): void
{
    FilamentColor::register([
        'danger' => Color::Red,
        'gray' => Color::Zinc,
        'info' => Color::Blue,
        'primary' => Color::Indigo,
        'success' => Color::Green,
        'warning' => Color::Amber,
    ]);
}
Enter fullscreen mode Exit fullscreen mode

In this example this script replace the Amber color as the primary color for the Indigo all of the Tailwind Colors Pallette is available in the Colors class provided by Filament.

You can add more color options and even customize them from hex color codes to customize it even more you can follow the docs for this section here

Thanks for reading!

filament Article's
30 articles in total
Favicon
Multi select default selection i filament v3
Favicon
Filament: Image Color Picker component
Favicon
My First No-Code SaaS Took off - $8K in 40 days
Favicon
Add a sidebar with options in a Filament resource
Favicon
Filament: Modify login or logout response
Favicon
Filament Database Notification Sound
Favicon
Laravel Nova vs Filament: The Best Admin Panels
Favicon
Filament: Add icon to form buttons
Favicon
Filament Breezy: add new field to Personal Info component
Favicon
Filament: Delete Attachments when Deleting a Record
Favicon
Filament: Generate Resource from Existing DB Schema
Favicon
Filament Breezy: set storage disk for avatar
Favicon
Laravel Stats : Filament Charts.js pour faire les statistiques
Favicon
Filament How to redirect to list page after (create,update) using Trait
Favicon
How to solve Symfony\Component\Routing\Exception\RouteNotFoundException Route [filament.admin.resources.api-keys.index] not
Favicon
Apa itu Laravel Filament?
Favicon
Laravel Filament: get resource table data by authenticated id
Favicon
Change Default Colors in FilamentPHP
Favicon
How to Use Searchable in Laravel 10 Filament v3
Favicon
Filament: add a confirmation password field in a form
Favicon
TomatoPHP Filament Plugins
Favicon
Debug Filament Search Query
Favicon
Filament PHP Blade UI Components Visually Explained
Favicon
Filament Context Menu
Favicon
How to Extend a Filament Resource
Favicon
Linkeeper - Lesson 02 - Start playing with Filament
Favicon
Linkeeper - Lesson 01 - Installation
Favicon
Filament has SPA mode!
Favicon
Access parent component value from the Repeater in Filament
Favicon
Filament v3 - Multi-tenancy form component scoping

Featured ones: