Tricks

Using a custom SVG in IconColumn

May 28, 2023
Patrick Boivin
Admin panel, Table builder

First, create a custom Blade component with your SVG code in it, for example:

resources/views/components/icons/high-score.blade.php

<svg>
...
</svg>

Then, use the name of your custom component instead of a heroicon- name:

IconColumn::make('score')
->options([
'icons.high-score' => fn ($state): bool => $state >= 66,
'icons.medium-score' => fn ($state): bool => $state >= 33 && $state < 66,
'icons.low-score' => fn ($state): bool => $state < 33,
]),

No comments yet…