Skip to main content
The select component allows you to select from a list of predefined options.

Basic Usage

use Filament\Forms\Components\Select;

Select::make('status')
    ->options([
        'draft' => 'Draft',
        'reviewing' => 'Reviewing',
        'published' => 'Published',
    ])

Available Methods

options
method
Sets the available options.
Select::make('status')
    ->options([
        'draft' => 'Draft',
        'published' => 'Published',
    ])
native
method
Use native HTML5 select (default is true).
Select::make('status')
    ->native(false) // Enable JavaScript select
searchable
method
Makes the select searchable.
Select::make('author_id')
    ->options(User::pluck('name', 'id'))
    ->searchable()

// Search across multiple columns
Select::make('author_id')
    ->relationship('author', 'name')
    ->searchable(['name', 'email'])
multiple
method
Allows multiple selections.
Select::make('technologies')
    ->multiple()
    ->options([
        'tailwind' => 'Tailwind CSS',
        'alpine' => 'Alpine.js',
        'laravel' => 'Laravel',
    ])
relationship
method
Configures the select to work with Eloquent relationships.
// BelongsTo relationship
Select::make('author_id')
    ->relationship(name: 'author', titleAttribute: 'name')

// BelongsToMany relationship (requires multiple())
Select::make('technologies')
    ->multiple()
    ->relationship(titleAttribute: 'name')

// With custom query
Select::make('author_id')
    ->relationship(
        name: 'author',
        titleAttribute: 'name',
        modifyQueryUsing: fn (Builder $query) => $query->withTrashed(),
    )
getSearchResultsUsing
method
Customizes how search results are retrieved.
Select::make('author_id')
    ->searchable()
    ->getSearchResultsUsing(fn (string $search): array => 
        User::where('name', 'like', "%{$search}%")
            ->limit(50)
            ->pluck('name', 'id')
            ->all()
    )
    ->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name)
getOptionLabelUsing
method
Customizes how option labels are displayed for single select.
Select::make('author_id')
    ->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name)
getOptionLabelsUsing
method
Customizes how option labels are displayed for multi-select.
Select::make('technologies')
    ->multiple()
    ->getOptionLabelsUsing(fn (array $values): array => 
        Technology::whereIn('id', $values)
            ->pluck('name', 'id')
            ->all()
    )
getOptionLabelFromRecordUsing
method
Customizes option labels from Eloquent records.
Select::make('author_id')
    ->relationship('author')
    ->getOptionLabelFromRecordUsing(
        fn (Model $record) => "{$record->first_name} {$record->last_name}"
    )
    ->searchable(['first_name', 'last_name'])
preload
method
Preloads options when the page loads.
Select::make('author_id')
    ->relationship('author', 'name')
    ->searchable()
    ->preload()
reorderable
method
Allows reordering multi-select options.
Select::make('technologies')
    ->multiple()
    ->reorderable()
createOptionForm
method
Adds a form to create new options.
Select::make('author_id')
    ->relationship('author', 'name')
    ->createOptionForm([
        TextInput::make('name')->required(),
        TextInput::make('email')->email()->required(),
    ])
createOptionUsing
method
Customizes how new options are created.
Select::make('author_id')
    ->createOptionUsing(function (array $data): int {
        return auth()->user()->team->members()->create($data)->getKey();
    })
editOptionForm
method
Adds a form to edit the selected option.
Select::make('author_id')
    ->relationship('author', 'name')
    ->editOptionForm([
        TextInput::make('name')->required(),
        TextInput::make('email')->email()->required(),
    ])
boolean
method
Creates a boolean select with Yes/No options.
Select::make('is_active')
    ->boolean()

// Customize labels
Select::make('feedback')
    ->boolean(
        trueLabel: 'Absolutely!',
        falseLabel: 'Not at all!',
        placeholder: 'Make your choice...'
    )
allowHtml
method
Allows HTML in option labels.
Select::make('status')
    ->options([
        'active' => '<span class="text-green-500">Active</span>',
        'inactive' => '<span class="text-red-500">Inactive</span>',
    ])
    ->allowHtml()
wrapOptionLabels
method
Controls whether option labels wrap or truncate.
Select::make('status')
    ->wrapOptionLabels(false) // Truncate long labels
selectablePlaceholder
method
Controls whether the placeholder can be selected.
Select::make('status')
    ->selectablePlaceholder(false)
    ->default('draft')
disableOptionWhen
method
Disables specific options.
Select::make('status')
    ->options([
        'draft' => 'Draft',
        'published' => 'Published',
    ])
    ->disableOptionWhen(fn (string $value): bool => $value === 'published')
optionsLimit
method
Limits the number of options displayed.
Select::make('author_id')
    ->relationship('author', 'name')
    ->searchable()
    ->optionsLimit(20)
loadingMessage
method
Sets a custom loading message.
Select::make('author_id')
    ->relationship('author', 'name')
    ->searchable()
    ->loadingMessage('Loading authors...')
noSearchResultsMessage
method
Sets a custom no results message.
Select::make('author_id')
    ->searchable()
    ->noSearchResultsMessage('No authors found.')
searchPrompt
method
Sets a custom search prompt.
Select::make('author_id')
    ->searchable()
    ->searchPrompt('Search authors...')
searchDebounce
method
Sets the search debounce in milliseconds.
Select::make('author_id')
    ->searchable()
    ->searchDebounce(500)
prefix
method
Adds text before the select.
Select::make('status')
    ->prefix('Status:')
suffix
method
Adds text after the select.
Select::make('domain')
    ->suffix('.com')
minItems
method
Sets minimum number of items for multi-select.
Select::make('technologies')
    ->multiple()
    ->minItems(1)
maxItems
method
Sets maximum number of items for multi-select.
Select::make('technologies')
    ->multiple()
    ->maxItems(3)
pivotData
method
Sets pivot data for BelongsToMany relationships.
Select::make('primaryTechnologies')
    ->relationship('technologies', 'name')
    ->multiple()
    ->pivotData(['is_primary' => true])

Common Patterns

Simple Select

Select::make('status')
    ->options([
        'draft' => 'Draft',
        'published' => 'Published',
    ])
    ->required()

Searchable Relationship

Select::make('author_id')
    ->relationship('author', 'name')
    ->searchable()
    ->preload()
    ->required()

Multi-Select with Relationship

Select::make('technologies')
    ->multiple()
    ->relationship('technologies', 'name')
    ->preload()

Grouped Options

Select::make('status')
    ->options([
        'In Process' => [
            'draft' => 'Draft',
            'reviewing' => 'Reviewing',
        ],
        'Reviewed' => [
            'published' => 'Published',
            'rejected' => 'Rejected',
        ],
    ])

Build docs developers (and LLMs) love