->colors(): Can multiple values share the same colours?

Can ->colors() in Filament TextColumn accept multiple values mapping to a single colour? Or does it only accept a single value per color? What’s the recommended way to handle multiple values that should share the same colour? For example:
->colors([
'danger' => ['Transfer Out', 'Removed'],
'success' => ['Transfer In', 'Added'],
])
->colors([
'danger' => ['Transfer Out', 'Removed'],
'success' => ['Transfer In', 'Added'],
])
Solution:
You can use that or resort to using enum (can configure color, description, labels and icons)
No description
Jump to solution
5 Replies
Dennis Koch
Dennis Koch4w ago
What is the use case? How can a color be multiple values at once? Oh it's about the TextColumn. Sorry
98.dev
98.devOP4w ago
Edited the original question, to mention this.
Zen Nitiruj
Zen Nitiruj4w ago
I think you would do something in closure like ->color(fn($record) => $record->transfer ==='out'? 'danger': 'success')
Solution
Kikechi
Kikechi4w ago
You can use that or resort to using enum (can configure color, description, labels and icons)
No description
98.dev
98.devOP3w ago
Thanks both 👍 👍 This turned out to be the cleanest way.

Did you find this page helpful?