How to change background-color of row on index page of resource in Laravel Nova?

Viewed 393

Depending on the content in the "status" column, the row should be of a certain color. For example, if the 'status' is 'null', then the row is yellow.

1 Answers

I would try using asHtml method:

Text::make('Status', function () {
    return view('partials.status', [
        'is_passing' => $this->isPassing(),
    ])->render();
})->asHtml()

It is described here: https://nova.laravel.com/docs/1.0/resources/fields.html#computed-fields

Since tailwindcss is all within your html you might be able to stick some timple logic in there.

Other then that I would look at one of custom nova packages and how they do this.

Hope it helps!

Related