Documentation Index
Fetch the complete documentation index at: https://mintlify.com/filamentphp/filament/llms.txt
Use this file to discover all available pages before exploring further.
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
Sets the available options.Select::make('status')
->options([
'draft' => 'Draft',
'published' => 'Published',
])
Use native HTML5 select (default is true).Select::make('status')
->native(false) // Enable JavaScript select
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'])
Allows multiple selections.Select::make('technologies')
->multiple()
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
])
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(),
)
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)
Customizes how option labels are displayed for single select.Select::make('author_id')
->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name)
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
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'])
Preloads options when the page loads.Select::make('author_id')
->relationship('author', 'name')
->searchable()
->preload()
Allows reordering multi-select options.Select::make('technologies')
->multiple()
->reorderable()
Adds a form to create new options.Select::make('author_id')
->relationship('author', 'name')
->createOptionForm([
TextInput::make('name')->required(),
TextInput::make('email')->email()->required(),
])
Customizes how new options are created.Select::make('author_id')
->createOptionUsing(function (array $data): int {
return auth()->user()->team->members()->create($data)->getKey();
})
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(),
])
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...'
)
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()
Controls whether option labels wrap or truncate.Select::make('status')
->wrapOptionLabels(false) // Truncate long labels
Controls whether the placeholder can be selected.Select::make('status')
->selectablePlaceholder(false)
->default('draft')
Disables specific options.Select::make('status')
->options([
'draft' => 'Draft',
'published' => 'Published',
])
->disableOptionWhen(fn (string $value): bool => $value === 'published')
Limits the number of options displayed.Select::make('author_id')
->relationship('author', 'name')
->searchable()
->optionsLimit(20)
Sets a custom loading message.Select::make('author_id')
->relationship('author', 'name')
->searchable()
->loadingMessage('Loading authors...')
Sets a custom no results message.Select::make('author_id')
->searchable()
->noSearchResultsMessage('No authors found.')
Sets a custom search prompt.Select::make('author_id')
->searchable()
->searchPrompt('Search authors...')
Sets the search debounce in milliseconds.Select::make('author_id')
->searchable()
->searchDebounce(500)
Adds text before the select.Select::make('status')
->prefix('Status:')
Adds text after the select.Select::make('domain')
->suffix('.com')
Sets minimum number of items for multi-select.Select::make('technologies')
->multiple()
->minItems(1)
Sets maximum number of items for multi-select.Select::make('technologies')
->multiple()
->maxItems(3)
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',
],
])