badge default color

Hi All,

I am implementing following Badge With Color : https://filamentphp.com/docs/3.x/tables/columns/text#displaying-as-a-badge

TextColumn::make('status')
->badge()
->color(fn (string $state): string => match ($state) {
'draft' => 'gray',
'reviewing' => 'warning',
'published' => 'success',
'rejected' => 'danger',
})

Is there anyway that i can set a default color if state does not exists?
Now it will trohw a exception / error

UnhandledMatchError
Unhandled match case 'created'

Thanks!
Solution
You can also just use an array of colors and anything that isn't in the array gets the primary color:
->colors([
    'gray' => 'draft',
    'warning' => 'reviewing', 
    //everything else will become 'primary'
]),

Note the keys/colors are reversed in this example
Was this page helpful?