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
ZedoX16mo 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}"];
})
nostrodamned
nostrodamnedOP16mo 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
ZedoX16mo 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
nostrodamned
nostrodamnedOP16mo 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
ZedoX16mo ago
That's why I suggested using ->extraAttributes() Which can be used to pass in custom classes/css styles
nostrodamned
nostrodamnedOP16mo 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
awcodes16mo ago
->color(function() {
$color = '#bada55';
return \Filament\Support\Colors\Color::hex($color);
})
->color(function() {
$color = '#bada55';
return \Filament\Support\Colors\Color::hex($color);
})
ZedoX
ZedoX16mo ago
Ah i totally forgot v3 comes with awesome color utilities
nostrodamned
nostrodamnedOP16mo ago
Bloominheck never new that was even possible @awcodes and @zedox thanks so much for support!!
Want results from more Discord servers?
Add your server