Question - set bodyAttribute of column based on the row value #771
-
I'm trying to set text/bg color of a row depending on its value. Example: status is active(green) and inactive(red) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Were you able to make progress on this? Would have been nicer if we could pass a closure and return the necessary styling. |
Beta Was this translation helpful? Give feedback.
-
You can use Action Rules, it might look something like this: final class MyTable extends PowerGridComponent
{
//...
public function actionRules(): array
{
return [
Rule::rows()
->when(fn($user) => (bool) $user->is_active === false)
->setAttribute('class', 'bg-yellow-50 hover:bg-red-100'),
Rule::rows()
->when(fn($user) => (bool) $user->is_active === true)
->setAttribute('class', 'bg-yellow-50 hover:bg-green-100')
];
} Also, you may check the classes in the default themes at your directory: |
Beta Was this translation helpful? Give feedback.
You can use Action Rules, it might look something like this:
Also, you may check the classes in the default themes at your directory:
vendor/power-components/livewire-powergrid/src/Themes/
, more info on custom themes in the…