F
Filament14mo ago
Bagus A

TextColumn Dynamic Color

In table we can change column color with
TextColumn::make('status')
->color('primary')
TextColumn::make('status')
->color('primary')
How can we change the color dynamically, for example if status is shipped then, it's success, if status is cancelled then it's danger.
2 Replies
einnlleinhatt_
einnlleinhatt_14mo ago
Like this ?
->color(fn (string $state): string => match ($state) {
'cancelled' => 'warning',
'shipped' => 'success',
})
->color(fn (string $state): string => match ($state) {
'cancelled' => 'warning',
'shipped' => 'success',
})
Bagus A
Bagus AOP14mo ago
Thanks @einnlleinhatt_
Want results from more Discord servers?
Add your server