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),
])
Solution:Jump to 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:...
5 Replies
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:
.task-urgent .text-gray-950 {
@apply !text-red-600;
}
The key was including that default gray text color.Correction: I did this for rows, not the group heading. But that's how I got rows to have a dynamic color.
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.
I hear you but couldn't find another way through the specificity stack. Was even surprised THIS worked. Open to ideas though.
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.