#table row background color & clear all filters button

8 messages · Page 1 of 1 (latest)

unkempt tree
#

Hi there.

I need to things:

  1. i want my first 4 records in the table to have green background and the last 4 records a red background. How can i achievie that?

  2. i'd like to disable or completly remove button to clear filters in table.

tidal vesselBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

mild dust
#

the first 4 no matter how they're sorted?

unkempt tree
mild dust
#

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

unkempt tree
#

Thank you very much, I will try it out!

unkempt tree
#

i found out i can also do something like this:

  ->state(static function ($rowLoop) {
                        $numOfRecords = $rowLoop->count;
                        if($rowLoop->iteration <= 4) {
                            return 'green';
                        }