Color/Colour Picker

In the color picker it stores hex or rgb values, but not tailwind colors (unless i am missing something) but textcolumn badges can only be tailwind colours. I am trying to allow the user to select a colour for statuses - how can i achieve this preferably using the built in colour picker! Thanks ALL
9 Replies
ZedoX
ZedoX2y ago
Off the top of my head I can think of doing something like
TextColumn::make('status')
->badge()
->extraAttributes(function ($record) {
$color = //get the color saved based on $record

return ['style' => "color:{$color}"];
})
TextColumn::make('status')
->badge()
->extraAttributes(function ($record) {
$color = //get the color saved based on $record

return ['style' => "color:{$color}"];
})
Bleak
BleakOP2y ago
yes but issue is that colorpicker only supports rgb, or hex - not tailwindcolors so when creating a new status i want user to be able to choose the color @ZedoX
ZedoX
ZedoX2y ago
I'm confused do you want to select tailwind colors or want the built-in color picker? This idea is for displaying based on the saved hex color
Bleak
BleakOP2y ago
there is two aspects, 1. In the admin let the user create statuses and choose a color for it 2. In a Table display the status using a badge which uses that color I cant use a table column with a badge columnt with hex colorus @ZedoX
ZedoX
ZedoX2y ago
That's why I suggested using ->extraAttributes() Which can be used to pass in custom classes/css styles
Bleak
BleakOP2y ago
Oh just got what you meant! Let me try that no sadly not I tried TextColumn::make('status.title')->label('Status') ->searchable() ->sortable() ->badge() ->extraAttributes(function ($record) { $color = '#666666'; return ['style' => "color:{$color}"]; }),
awcodes
awcodes2y ago
->color(function() {
$color = '#bada55';
return \Filament\Support\Colors\Color::hex($color);
})
->color(function() {
$color = '#bada55';
return \Filament\Support\Colors\Color::hex($color);
})
ZedoX
ZedoX2y ago
Ah i totally forgot v3 comes with awesome color utilities
Bleak
BleakOP2y ago
Bloominheck never new that was even possible @awcodes and @zedox thanks so much for support!!

Did you find this page helpful?