public function configure(): void
{
$this->setPrimaryKey('id')
->setTrAttributes(function ($row, $index) {
// Apply different classes based on success rate
return [
'default' => true, // keep the package's built-in row classes
'class' => match (true) {
$row->success_rate >= 80 => 'bg-green-50 dark:bg-green-900/20',
$row->success_rate >= 50 => 'bg-yellow-50 dark:bg-yellow-900/20',
$row->success_rate >= 25 => 'bg-orange-50 dark:bg-orange-900/20',
default => 'bg-red-50 dark:bg-red-900/20',
},
];
});
}
Note on the v3 API
Row styling is done with setTrAttributes(Closure $callback). The closure receives
($row, $index) and must return an array of attributes rather than a
class string. Set 'default' => true to keep the package's built-in row classes
(striping and hover); omit it or set it to false to replace them entirely.
Passing a plain string or an array of classes is not supported.
Color Legend (Success Rate)
Live Demo
Notice how rows are colored based on their success rate
You are not connected to the internet.
| 1 | Miss Eve Will | [email protected] | 97% | |
| 2 | Mr. Cornelius Hansen DDS | [email protected] | 17% | |
| 3 | Dr. Albertha Abbott | [email protected] | 70% | |
| 4 | Citlalli Berge PhD | [email protected] | 26% | |
| 5 | Mr. Austen Harber | [email protected] | 35% | |
| 6 | Raegan Pfannerstill PhD | [email protected] | 60% | |
| 7 | Dan Ebert | [email protected] | 21% | |
| 8 | Mertie Kohler | [email protected] | 56% | |
| 9 | Prof. Cornelius Herzog DDS | [email protected] | 41% | |
| 10 | Barbara Metz | [email protected] | 37% |
Showing 1 to 10 of results