Skip to main content
← Back to Table of Contents

Summary

Styled Filament Select with pill trigger, rich option rows, grid layout, and multi-select chips. Extends Filament Selectall native Select APIs remain available.
ClassBjanczak\FilamentFlexFields\Filament\Forms\Components\SelectField
ExtendsFilament\Forms\Components\Select
State typestring|int|null (single) · array (multiple)
Model cast'category_id' => 'integer' · 'tags' => 'json' (multiple)
FieldTypeselect, multi_select
Playgroundselect-field slug in Flex Fields playground
Works with all standard Filament field APIs: required(), disabled(), hidden(), live(), afterStateUpdated(), validation rules, etc.

Basic usage

Standard select with rich options

use Bjanczak\FilamentFlexFields\Filament\Forms\Components\SelectField;

SelectField::make('framework')
    ->label('Framework')
    ->options([
        'laravel' => [
            'label' => 'Laravel',
            'description' => 'The PHP Framework for Web Artisans',
            'icon' => 'heroicon-o-bolt',
            'badge' => 'v11',
        ],
        'livewire' => [
            'label' => 'Livewire',
            'description' => 'Full-stack framework for Laravel',
            'icon' => 'heroicon-o-sparkles',
        ],
    ])
    ->searchable()
    ->variant('bordered')
    ->size('md');

Multi-select with chips

use Bjanczak\FilamentFlexFields\Filament\Forms\Components\SelectField;

SelectField::make('tags')
    ->multiple()
    ->options([
        'draft' => 'Draft',
        'published' => 'Published',
        'archived' => 'Archived',
    ])
    ->chipColor('primary')
    ->required();

State & validation

Stored value

State is the option key from options().
// Single select
$record->category_id; // int|string|null — e.g. 1

// Multi-select
$record->tags; // array — e.g. ['draft', 'published']

Default state

The field defaults to null (single) or [] (multiple).
SelectField::make('category_id')
    ->default(1);

Validation rules

RuleWhen
nullableAlways (unless required())
Rule::in(...)Value must match a configured option key
requiredWhen ->required()

Configuration API

All methods accept Closure unless noted.
MethodTypeDefaultDescription
variant(string|Closure $variant)Setup'bordered'Visual style: bordered, secondary, flat, faded, soft, underlined, item-card
color(string|Closure|null $color)SetupnullAccent color for the field
chipColor(string|Closure $chipColor)Setup'neutral'Color for multi-select chips
richOptions(bool|Closure $condition = true)SetupautoForce rich option rendering
optionLayout(string|Closure $layout)Setup'list'Dropdown layout: list, grid
inlineFieldLabel(bool|Closure $condition = true)SetupfalseRender label inside the field track
inlineSearch(bool|Closure $condition = true)SetupfalseRender search input inside the dropdown
clearable(bool|Closure $condition = true)SetupautoShow clear button (×)
dropdownAlign(string|Closure $align)SetupautoAlign dropdown: start, end
size(string|ControlSize|Closure $size)Setup'md'Control size: sm, md, lg
rounding(string|Closure|null $rounding)SetupconfigBorder radius token

variant()

SelectField::make('category_id')->variant('soft');
SelectField::make('category_id')->variant('underlined');

optionLayout()

Use grid for a multi-column visual picker:
SelectField::make('theme')
    ->options([
        'light' => ['label' => 'Light', 'icon' => 'heroicon-o-sun'],
        'dark' => ['label' => 'Dark', 'icon' => 'heroicon-o-moon'],
    ])
    ->optionLayout('grid');

inlineSearch()

Recommended for searchable selects to keep the UI compact:
SelectField::make('user_id')
    ->searchable()
    ->inlineSearch();

Real-world examples

User select with avatars

SelectField::make('user_id')
    ->label('Assignee')
    ->options(User::all()->mapWithKeys(fn ($user) => [
        $user->id => [
            'label' => $user->name,
            'description' => $user->email,
            'image' => $user->avatar_url,
        ],
    ]))
    ->searchable()
    ->inlineSearch()
    ->variant('soft');

Multi-select tags in a Section

Section::make('Metadata')
    ->schema([
        SelectField::make('tags')
            ->multiple()
            ->relationship('tags', 'name')
            ->chipColor('success')
            ->preload(),
    ])

Playground

/admin/flex-fields-playground/select-field See Playground for setup.
ComponentWhen to use instead
FlexRadiolistWhen all options should be visible at once
ChoiceCardsLarge card-style selection with more detail
DualListboxFieldWhen managing large sets of selected items

CSS classes (reference)

ClassRole
fff-select-fieldRoot wrapper
fff-select-field--{sm|md|lg}Size modifier
fff-select-field--{variant}Visual variant
fff-select-field--layout-{list|grid}Option layout
fff-select-field--chips-{color}Multi-select chip color
fff-select-field--inline-field-labelInline label active
fff-select-field--inline-searchInline search active

Performance

MechanismWhat it does
Lazy CSSLoads select-field styles only when the field renders
JS TransformationEfficiently prepares rich options for the frontend component
Search CacheMemoizes search results to reduce server round-trips