#table row background color & clear all filters button
8 messages · Page 1 of 1 (latest)
the first 4 no matter how they're sorted?
I could disable sorting if needed.
You’ve got any idea how can I do that?
It’s basically a sport table, I want top teams to have custom colours and the worse teams too
ok. I mean if you don't sort, you can do it with simple CSS but only for the first 4.
/* First 4 are green */
.fi-ta-row:nth-child(1), .fi-ta-row:nth-child(2), .fi-ta-row:nth-child(3), .fi-ta-row:nth-child(4) {
background-color: rgba(34, 197, 94, 0.3);
}
But for the last four it's not possible in CSS because of pagination.
However, you could do that on php side with recordClasses :
->recordClasses(fn(YourModel $record) => match (true) {
$record->isInTop4() => 'border-s-2 !border-s-green-600 !dark:border-s-green-300',
$record->isInBottom4() => 'border-s-2 !border-s-red-600 !dark:border-s-red-300',
default => '',
})
you may need a custom theme if you use tailwind classes that haven't been used yet by filament
Thank you very much, I will try it out!
i found out i can also do something like this:
->state(static function ($rowLoop) {
$numOfRecords = $rowLoop->count;
if($rowLoop->iteration <= 4) {
return 'green';
}