F
Filament14mo ago
Emaz

extraAttributes on Groups

Is it possible to give my group headings extraAttributes so I can give them some color? I'd like to have the description font be red for urgent. ->groups([ Group::make('priority') ->getDescriptionFromRecordUsing(fn (ToDo $record): string => match ($record->priority) { '1. Urgent' => 'Needs to be done ASAP', '2. Easy' => 'A fast task you can knock off your list', '3. Short Term' => 'An ordinary task that can be done soon', '4. Long Term' => 'Requires more planning, time and possibly resources', default => 'Unknown priority', // Handle any other values }) ->titlePrefixedWithLabel(false), ])
No description
Solution:
In case anyone stumbles on this, the only way I was able to make it work was: 1. custom theme 2. In that theme I had to have a selector geared towards that specific text color that was rendering. I basically set classes using recordClasses and then in my theme css I had to have a very specific selector:...
Jump to solution
5 Replies
Solution
Emaz
Emaz14mo ago
In case anyone stumbles on this, the only way I was able to make it work was: 1. custom theme 2. In that theme I had to have a selector geared towards that specific text color that was rendering. I basically set classes using recordClasses and then in my theme css I had to have a very specific selector: .task-urgent .text-gray-950 { @apply !text-red-600; } The key was including that default gray text color.
Emaz
EmazOP14mo ago
Correction: I did this for rows, not the group heading. But that's how I got rows to have a dynamic color.
awcodes
awcodes14mo ago
I would try to find a more solid way to target it. Targeting a tailwind class name like this is prone to breaking if filament ever changes it. Glad it’s working for you though.
Emaz
EmazOP14mo ago
I hear you but couldn't find another way through the specificity stack. Was even surprised THIS worked. Open to ideas though.
awcodes
awcodes14mo ago
I’d maybe look into modern css ways of targeting element with out using class. You’d be surprised what css is capable of these days.
Want results from more Discord servers?
Add your server