// DOCS ICON SELECT COLUMN 1.x
Outdated

You are reading the documentation for 1.x. The current version is 3.x.

View 3.x docs →

Usage

With an enum

The column works best with a backed enum. The enum should implement HasLabel and HasIcon, and can implement HasColor, as described in the filament documentation:

use Guava\FilamentIconSelectColumn\Tables\Columns\IconSelectColumn;

$table->columns([
    IconSelectColumn::make('status')
        ->options(Status::class),
]);

With arrays

Alternatively, you can pass the options and their icons directly to the column:

IconSelectColumn::make('priority')
    ->options([
        'low' => 'Low',
        'high' => 'High',
    ])
    ->icons([
        'low' => 'heroicon-o-chevron-down',
        'high' => 'heroicon-o-chevron-up',
    ])
    ->colors([
        'low' => 'gray',
        'high' => 'danger',
    ]);

Close on selection

By default the dropdown stays open after a selection. To close it automatically, use closeOnSelection():

IconSelectColumn::make('status')
    ->closeOnSelection();

Validation

The column only accepts values present in the options, so a manipulated request cannot write arbitrary values to the record.

guava/filament-icon-select-column 10K installs · 46 stars
// COOKIES

A few cookies keep the site working; others remember preferences or count visits. You choose what runs.

Cookie policy