Combobox
Basic Usage
The Combobox field renders a selection control for known values. To offer a finite list of choices, pass them to the options method. By default, a single non-searchable choice renders as a native select. For free-form string tokens or record-backed selections, see the Tokens and Records sections.
use InertiaUI\Forms\Fields\Combobox;
Combobox::make('region')
->options([
'north' => 'North region',
'central' => 'Central region',
'remote' => 'Remote team',
])
->default('central')
->placeholder('Choose a region');Search, multiple selection, custom values, tokens, records, rich rows, and selected media automatically switch to the non-native combobox control. There is no public native() method. Short lists are often better as Radio::buttons() or CheckboxGroup::buttons(), especially when all available choices should stay visible.
Option Value Types
Finite choices may use string, numeric, or boolean values. Keyed option arrays are the shortest way to write string and numeric values. Boolean values should use explicit value and label rows, so the submitted value stays a boolean.
Native <select> elements expose changed values as strings in the DOM, so Combobox resolves the selected DOM value to the normalized option before submitting. The form data keeps the original PHP type of the option value:
Combobox::make('priority')
->options([
1 => 'Low',
2 => 'Normal',
3 => 'High',
])
->default(2);
Combobox::make('notifications_enabled')
->options([
['value' => true, 'label' => 'Enabled'],
['value' => false, 'label' => 'Disabled'],
])
->default(false);Non-native combobox controls select the normalized option value directly.
Grouped Native Choices
To keep related values together, you may group the options array by name and call the groupBy method. Grouped options still work as finite choices:
Combobox::make('workflow_status')
->label('Status')
->options([
'Workflow' => [
'draft' => 'Draft',
'review' => 'In review',
],
'Release' => [
'approved' => 'Approved',
'published' => 'Published',
],
])
->groupBy()
->default('review');Model and Query Paging
Options backed by a model or query automatically use Inertia Infinite Scroll once the form serializes the field. This applies when the source is a model class, an Eloquent builder, a query builder, or a closure that returns one. There is no row-count threshold:
Combobox::make('assignee_id')
->options(User::class, label: 'name', value: 'id');To use Eloquent but keep the field as a finite option list, resolve the builder to a collection:
$users = User::query()
->orderBy('name')
->get();
Combobox::make('assignee_id')
->options($users, label: 'name', value: 'id');A bare model class is automatically ordered by the label column when the label is a simple column name. An Eloquent or query builder keeps its own order, so add orderBy(...) yourself. For Eloquent sources, dotted relation paths such as team.name are eager loaded automatically.
Each Infinite Scroll request loads 25 options by default. You may change this page size using the perPage method:
Combobox::make('assignee_id')
->options(User::class, 'name', 'id')
->perPage(10);Searchable Choices
To search the options locally, use the searchable method. Search ignores case and accents. It matches the option label, description, disabled reason, selected suffix, and submitted value:
Combobox::make('country')
->options([
'nl' => 'Netherlands',
'be' => 'Belgium',
'de' => 'Germany',
'fr' => 'France',
])
->searchable()
->clearable()
->default('nl')
->placeholder('Search countries');The autofocus method focuses choice-mode controls on page load. Simple finite choices focus the native select. Searchable choices, multiple choices, and choices that allow custom values focus the custom input. Tokens and records don't autofocus through Combobox:
Combobox::make('country')
->options(Country::pluck('name', 'code'))
->autofocus();Multiple Choices
To save an array of selected option values, use the multiple method. The field stays in choice mode. It doesn't switch to tokens or records:
Combobox::make('reviewers')
->options([
'copy' => 'Copy review',
'accessibility' => 'Accessibility review',
'release' => 'Release review',
])
->multiple()
->maxSelected(3)
->placeholder('Search reviewers')
->default(['copy', 'accessibility']);Custom Values
To let a choice list accept a one-off value in addition to the existing options, use the allowCustomValues method. A local value that the user types into such a field is submitted as the typed string:
Combobox::make('topics')
->options([
'planning' => 'Planning',
'research' => 'Research',
'review' => 'Review',
'launch' => 'Launch',
])
->multiple()
->allowCustomValues()
->clearable()
->placeholder('Add a topic')
->customValueText('Add "%s" as a topic')
->default(['planning']);In choice mode, a list array submits its integer array keys as values. Use domain keys or explicit value and label rows when the saved values matter.
Tokens
The tokens method turns the field into typed string tokens. The submitted value is an array of strings, and each value is shown as a tag. Tokens are the better fit for lists with token constraints, delimiters, or token-specific validation. Suggestions come from the options method, and custom tokens are allowed by default:
Combobox::make('topics')
->tokens()
->options(['Planning', 'Research', 'Review', 'Launch'])
->default(['Research'])
->placeholder('Type a topic');Suggestions from the database use the options method too. For tokens, use the same column for label and value, so selecting a suggestion submits the displayed token text:
Combobox::make('topics')
->tokens()
->options(Topic::query()->orderBy('name'), label: 'name', value: 'name')
->placeholder('Type a topic');Bound or default strings don't need to appear in the options. Existing saved tokens remain visible and submit as strings, as long as custom tokens are allowed:
Combobox::make('topics')
->tokens()
->options(['Planning', 'Research'])
->default(['Research', 'Quarterly review']);Suggestions Only
To restrict tokens to the suggestion list, pass false to the allowCustomValues method. This adds array validation on the field and Rule::in(...) validation for each submitted token:
Combobox::make('departments')
->tokens()
->options(['Engineering', 'Design', 'Marketing', 'Sales'])
->allowCustomValues(false);Limits and Rejection Rules
The minSelected and maxSelected methods validate the number of selected tokens. The maxLength method limits the token length in the browser and on the server. JavaScript and PCRE are different regex dialects, so regex validation uses two explicit methods. The pattern method is the authoritative server rule, and the browserPattern method is an optional browser constraint:
Combobox::make('slugs')
->tokens()
->label('Slugs')
->placeholder('Try qa-review')
->options(['release-plan', 'qa-review', 'launch-notes'])
->maxSelected(3)
->maxLength(16)
->pattern('/^[a-z0-9-]+$/D')
->browserPattern('^[a-z0-9-]+$')
->clearable()
->default(['release-plan']);The pattern method accepts a complete PHP PCRE expression, including delimiters and modifiers, and adds a regex rule to {field}.*. Invalid expressions throw during field configuration.
The browserPattern method accepts JavaScript regex source without delimiters for browser feedback. Inertia Forms doesn't translate between regex dialects, so call both methods explicitly when the browser should mirror the server rule.
Combobox doesn't provide a minLength() method. To require a minimum token length, use the rules method.
Delimiters, Duplicates, and Blur
Pressing Enter or typing the configured delimiter commits the current text as a token. The default delimiter is a comma. Duplicate detection is case-insensitive by default:
Combobox::make('emails')
->tokens()
->delimiter(';')
->allowDuplicates()
->caseSensitive()
->createOnBlur(false);The createOnBlur option defaults to true, so pending input becomes a token as focus leaves the field. Pressing Tab commits the pending token and advances focus. The frontend announces a rejected token when the duplicate, length, pattern, or suggestion rules prevent it from being added. Suggested tokens use the same listbox keyboard navigation and no-results state as choice Combobox fields.
Fields that use token-only helpers need the tokens method. These helpers are delimiter(), allowDuplicates(), caseSensitive(), pattern(), browserPattern(), maxLength(), and createOnBlur(). The allowCustomValues(), minSelected(), and maxSelected() methods are shared by multiple choices, tokens, and records.
Reorderable, Clearable, and Styled Tokens
Selected tokens may be reordered and cleared:
Combobox::make('steps')
->tokens()
->label('Workflow steps')
->placeholder('Add a step')
->options(['Draft', 'Reviewed', 'Ready', 'Final review', 'Published'])
->reorderable()
->clearable()
->default(['Draft', 'Reviewed']);The reorderable method lets users change the order of the selected tokens, and the submitted name[] values keep that order. The clearable method shows a clear-all control for the selected tokens. To style the tag badges, use the tagClass method:
Combobox::make('priorities')
->tokens()
->tagClass('bg-blue-50 text-blue-700 ring-1 ring-blue-200');Advanced Mapping and Rich Rows
The options method accepts keyed arrays, arrays of records, Collections, model classes, Eloquent builders, query builders, closures, and Arrayable values. Keyed arrays map their keys to submitted values and their values to labels:
Combobox::make('country')
->options(['us' => 'United States', 'ca' => 'Canada']);Record arrays use the value and label keys by default. For richer records, you may pass a label key, value key, description key, or callbacks:
Combobox::make('plan_id')
->options(
Plan::query()
->active()
->orderBy('name'),
label: 'name',
value: 'id',
description: fn (Plan $plan) => $plan->summary,
);Flat record arrays may be grouped by a field key:
Combobox::make('assignee_id')
->options([
['id' => 1, 'name' => 'Avery Stone', 'role' => 'Admins'],
['id' => 2, 'name' => 'Morgan Vale', 'role' => 'Editors'],
['id' => 3, 'name' => 'Jordan Example', 'role' => 'Admins'],
], label: 'name', value: 'id')
->groupBy('role');To build rich static options in PHP, use Option::make():
use InertiaUI\Forms\Fields\Support\Option;
use InertiaUI\Forms\Fields\Support\OptionImage;
Combobox::make('workspace_tool')
->options([
Option::make('mara-finch', 'Mara Finch')
->description('Shared tokens and review notes.')
->icon('PaletteIcon')
->avatar(
OptionImage::make('/avatars/mara-finch.jpeg')
->alt('Mara Finch')
->small()
)
->badge('Pinned')
->url('/team/mara-finch')
->metadata(['stack' => 'design'])
->selectedSuffix('Current'),
]);The frontend renders leading media in this order: image, then avatar, then icon. The image and avatar values accept a plain URL or an OptionImage payload. JSON endpoints may send these payload keys:
| Key | Use |
|---|---|
url / src | Image URL. One is required for object payloads. |
alt | Image alt text. |
title | Optional image title. |
size | Preset size: xs, sm, md, lg, or xl. |
rounded | Boolean roundness override. |
width / height | Explicit image dimensions. |
class | Extra image classes. |
The OptionImage builder methods include url(), to(), alt(), title(), size(), small(), medium(), large(), extraLarge(), rounded(), square(), width(), height(), dimensions(), and class().
To group static options explicitly, nest them under group names and call the groupBy method. The options don't need an extra group key:
Combobox::make('workspace_tool')
->options([
'Design' => [
Option::make('design-kit', 'Design kit'),
Option::make('style-guide', 'Style guide'),
],
'Delivery' => [
Option::make('release-board', 'Release board'),
],
])
->groupBy();Eloquent model and query options may be grouped by a model accessor, relation path, or callback. In these examples, Project and User are Eloquent models:
Combobox::make('project_id')
->options(Project::query()->orderBy('name'), label: 'name', value: 'id')
->groupBy('team.name');
Combobox::make('assignee_id')
->options(User::query()->orderBy('name'), label: 'name', value: 'id')
->groupBy(fn (User $user) => $user->team?->name ?? 'Unassigned');To translate group values into labels, use the mapGroupAs method. An array maps the raw group value. A callback receives the source row and the optional source key, so it may read sibling attributes:
Combobox::make('status')
->options([
['code' => 'pending', 'name' => 'draft', 'role_id' => 10],
['code' => 'published', 'name' => 'live', 'role_id' => 20],
], label: 'name', value: 'code')
->groupBy('role_id')
->mapGroupAs([
10 => 'Internal',
20 => 'Public',
]);
Combobox::make('assignee_id')
->options([
['id' => 1, 'name' => 'Avery Stone', 'role_id' => 10, 'role_name' => 'admin'],
['id' => 2, 'name' => 'Morgan Vale', 'role_id' => 20, 'role_name' => 'editor'],
], label: 'name', value: 'id')
->groupBy('role_id')
->mapGroupAs(fn (array $user) => str($user['role_name'])
->title()
->plural()
->toString());The groupBy method needs the complete option list, so grouped options backed by a model or query resolve as finite options and don't use Inertia Infinite Scroll. A closure passed to optionValue() or mapValueAs() falls back to finite options in the same way. To page a large model or query source through Inertia Infinite Scroll, keep it ungrouped and map its values with a string key.
The option mapping helpers also cover icons, badges, URLs, metadata, disabled states, and selected-item suffix text. Icon keys require a frontend resolver. See Icons for the iconResolver setup. This example combines several of them:
Combobox::make('workspace_tool')
->options([
'Design stack' => [
Option::make('design-kit', 'Design kit')
->description('Shared tokens, preview states, and review notes.')
->icon('PaletteIcon')
->selectedSuffix('Pinned'),
Option::make('illustration-brief', 'Illustration brief')
->description('Requests diagrams or small UI artwork.')
->icon('PenToolIcon'),
],
'Delivery stack' => [
Option::make('release-board', 'Release board')
->description('Tracks approvals, owners, and blocked tasks.')
->icon('PanelsTopLeftIcon'),
Option::make('deploy-runner', 'Deploy runner')
->description('Requires release captain approval.')
->icon('ServerIcon')
->disabled(reason: 'Locked during the release freeze.'),
],
'People shortcuts' => [
Option::make('team-duty', 'Team duty contact')
->description('Routes urgent questions to the current owner.')
->icon('UserRoundIcon'),
Option::make('ops-support', 'Operations support')
->icon('ShieldCheckIcon'),
],
])
->groupBy()
->searchable()
->clearable()
->placeholder('Search tools')
->emptyText('No tools available')
->noResultsText('No tools found')
->withSelectedOptionMedia()
->default('design-kit');Query-backed options use the same helpers against model attributes:
Combobox::make('workspace_tool')
->options(Tool::query()->orderBy('name'), label: 'name', value: 'id')
->groupBy('category')
->optionIcon('icon')
->optionBadge('badge')
->optionDisabled('locked')
->optionDisabledReason('locked_reason')
->optionSelectedSuffix('status');Resolving Labels
To resolve the option label from a source record key, relation path, or callback, use the optionLabel method. Passing label: to the options method is a shortcut for the common case:
Combobox::make('assignee_id')
->options(User::query()->orderBy('name'), value: 'id')
->optionLabel('name');Remapping Labels
To translate an already resolved source value to a display label, use the mapAs method:
Combobox::make('status')
->options([
['code' => 'draft', 'name' => 'draft'],
['code' => 'review', 'name' => 'review'],
], label: 'name', value: 'code')
->mapAs([
'draft' => 'Draft',
'review' => 'In review',
]);Adjusting Built Options
To apply custom logic to the final option after the base mappings run, use the mapOptionAs method. It receives the normalized Option, the source record, and the source key:
Combobox::make('feature_id')
->options(Feature::query()->orderBy('name'), value: 'id')
->mapOptionAs(fn (Option $option, Feature $feature) => $option
->label($feature->name)
->description($feature->summary)
->metadata(['owner' => $feature->owner_id]));Mapping Reference
Each mapping method resolves or remaps one part of an option:
| Method | Use |
|---|---|
optionValue() | Resolve the submitted option value from a key, relation path, or callback. |
mapValueAs() | Remap the resolved submitted value. |
optionDescription() / mapDescriptionAs() | Resolve or remap secondary row text. |
optionImage() / mapImageAs() | Resolve or remap larger row or selected media. |
optionAvatar() / mapAvatarAs() | Resolve or remap avatar media. |
optionIcon() / mapIconAs() | Resolve or remap a frontend icon key. |
optionBadge() / mapBadgeAs() | Resolve or remap trailing badge text. |
optionUrl() / mapUrlAs() | Resolve or remap an associated URL for custom slots. |
optionMetadata() / mapMetadataAs() | Resolve or remap structured application metadata. |
optionDisabled() / mapDisabledAs() | Resolve or remap disabled rows. |
optionDisabledReason() / mapDisabledReasonAs() | Resolve or remap disabled row explanations. |
optionSelectedSuffix() / mapSelectedSuffixAs() | Add compact selected-value suffix text. |
groupBy() / mapGroupAs() | Group flat arrays, query rows, or relation paths. |
Selected Media
Record selections use withSelectedRecordMedia(), as the Records examples below show. To show the mapped media of the option row in selected choice values, use the withSelectedOptionMedia method:
Combobox::make('workspace_tool')
->options(Tool::query(), label: 'name', value: 'id')
->optionIcon('icon')
->withSelectedOptionMedia();Records
Use the records method when the submitted value belongs to an application record and the selected record should keep display metadata around that value. Tokens submit the text they show. Records submit the configured value and render from a selected record payload, such as a label, email, avatar, disabled state, or metadata. A multiple record field may also become a sortable row list using the reorderable method, as shown later in this section:
$options = [
['id' => 1, 'name' => 'Mara Finch', 'email' => 'mara@example.com', 'avatar' => '/avatars/mara-finch.jpeg'],
['id' => 2, 'name' => 'Noel Park', 'email' => 'noel@example.com', 'avatar' => '/avatars/noel-park.jpeg'],
['id' => 3, 'name' => 'Iris Vale', 'email' => 'iris@example.com', 'avatar' => '/avatars/iris-vale.jpeg'],
['id' => 4, 'name' => 'Avery Stone', 'email' => 'avery@example.com', 'avatar' => '/avatars/avery-stone.jpeg'],
];
Combobox::make('author_id')
->records()
->label('Author')
->placeholder('Search users')
->options($options, label: 'name', value: 'id', description: 'email')
->withSelectedRecordMedia()
->clearable()
->default(2);Options backed by a model or query use the same Inertia Infinite Scroll path described in Model and Query Paging. The records method changes the selected-value contract, not whether the option source may page through Inertia:
Combobox::make('assignee_id')
->records()
->options(User::query()->orderBy('name'), label: 'name', value: 'id')
->perPage(10);Record rows may include disabled and disabledReason keys. Disabled rows remain visible in the dropdown but aren't selectable. The shared disabled() field method locks the currently selected records and keeps their selected display visible:
Combobox::make('reviewer_ids')
->records()
->options([
[
'id' => 1,
'name' => 'Avery Stone',
'disabled' => true,
'disabledReason' => 'Already assigned',
],
['id' => 2, 'name' => 'Morgan Vale'],
], label: 'name', value: 'id')
->default([1])
->multiple()
->disabled();Multiple record lists submit an ordered array of selected IDs. Only add the reorderable method to a records field when that selected order matters:
Combobox::make('reviewer_ids')
->records()
->label('Reviewers')
->options([
['value' => 'content', 'label' => 'Content desk'],
['value' => 'design', 'label' => 'Design desk'],
['value' => 'support', 'label' => 'Support desk'],
['value' => 'ops', 'label' => 'Operations desk'],
])
->selected([
['value' => 'content', 'label' => 'Content desk'],
['value' => 'design', 'label' => 'Design desk'],
])
->default(['content', 'design'])
->multiple()
->reorderable()
->maxSelected(3);The maxSelected method caps the number of records the user may select. The minSelected(), maxSelected(), exists(), and distinct() methods are reflected in the generated validation rules for record IDs. In records mode, the maxItemsText method replaces the message shown once the maxSelected() limit is reached:
Combobox::make('approval_reviewer_ids')
->records()
->label('Approval reviewers')
->placeholder('Add reviewers')
->options([
[
'value' => 'copy',
'label' => 'Copy review',
'description' => 'Checks wording and tone.',
],
[
'value' => 'legal',
'label' => 'Legal review',
'description' => 'Already assigned to this launch.',
'disabled' => true,
'disabledReason' => 'Already assigned to this launch.',
],
[
'value' => 'security',
'label' => 'Security review',
'description' => 'Checks access and sensitive changes.',
],
[
'value' => 'release',
'label' => 'Release review',
'description' => 'Final approval before publishing.',
],
])
->selected([
[
'value' => 'copy',
'label' => 'Copy review',
'description' => 'Checks wording and tone.',
],
])
->default(['copy'])
->multiple()
->maxSelected(2)
->maxItemsText('Two reviewers maximum');Remote Endpoints
Records backed by an endpoint use the source method for search and pagination. A separate selectedSource() endpoint may resolve the selected labels on edit forms. Without selectedSource(), the frontend falls back to the source endpoint, sends the configured valuesParam() key, and includes selected=1.
Combobox::make('author_id')
->records()
->source('/api/users')
->selectedSource('/api/users/selected')
->withSelectedRecordMedia()
->exists(User::class, 'id')
->placeholder('Search users');For search-only option endpoints, use the searchOptionsUsing method. It sends the current query as q and search, expects option rows back, and bypasses Inertia Infinite Scroll. Use the source method for records, selected lookups, request context, and paged sources.
To pass selected rows that are already known during server rendering, use the selected method. It seeds the display metadata for the current value, but it doesn't set the submitted value. Use default() or bound form data for the value:
Combobox::make('author_id')
->records()
->source('/api/users')
->selected(fn (mixed $value) => User::query()
->whereKey($value)
->get()
->map(fn (User $user) => [
'value' => $user->id,
'label' => $user->name,
'description' => $user->email,
]));Source Lifecycle and Paging
Record sources offer controls for request context, search, preloading, paging, and state text. Endpoint results use the configured pageParam() and perPage() values for infinite-scroll style paging. The preload method fetches the first page when the dropdown opens. Passing it an integer requests that many items, but only for page 1 with an empty query. Later pages and searched requests use perPage():
Combobox::make('reviewer_ids')
->records()
->source('/api/users')
->params(fn () => ['team' => 7, 'tenant' => tenant('id')])
->filters(fn () => ['active' => true])
->scopes(['reviewable', 'verified'])
->searchParam('term')
->valuesParam('ids')
->pageParam('p')
->perPageParam('size')
->perPage(50)
->minSearchLength(2)
->debounce(150)
->preload(10) // first empty-query page only
->emptyText('Type a user name')
->noResultsText('No users found')
->loadingText('Loading users')
->errorText('Could not load users');The params method sends fixed request context as top-level request data. The filters method sends nested filters data, and the scopes method sends a list of named source hints. Search requests, selected-value lookups, Inertia option reloads, and quick-create requests all receive the same context. Scopes are hints, not executable input, so endpoint code should allow-list the accepted scope names before applying query scopes.
The minSearchLength method waits for enough typed characters before a remote search. The debounce method delays the remote search after typing. The records method makes inline record options searchable by default. For inline or preloaded records that shouldn't filter locally, use searchable(false). Records backed by an endpoint remain searchable, because the source URL handles search.
Quick create persists a new record and selects the returned item. The field stays in record mode because it calls records() explicitly:
Combobox::make('assignee_id')
->records()
->source('/api/users')
->createRecordUsing('/api/users', method: 'post', param: 'name')
->createRecordText('Add "%s"')
->canCreateRecord(auth()->user()->can('create', User::class));The param argument controls the primary request body key. The frontend also sends q as a query mirror when the primary key isn't q. The body always includes params, filters, and scopes:
{
"name": "Avery Stone",
"q": "Avery Stone",
"params": { "tenant": "acme" },
"filters": { "active": true },
"scopes": ["reviewable"]
}The createRecordText method accepts a %s or {query} placeholder for the typed query. Passing false to the canCreateRecord method hides the create option, but the endpoint should still authorize writes and validate the request. A successful create endpoint may return a bare item:
{ "value": 5, "label": "Avery Stone" }It may also return the item in an item wrapper:
{ "item": { "value": 5, "label": "Avery Stone" } }Endpoint Response Shape
For a pageable endpoint, return the raw array from a Laravel paginator's toArray() result. This is the preferred server response, because it matches Laravel's default JSON pagination shape. The frontend reads data, current_page, per_page, total, last_page, and next_page_url:
Route::get('/api/users', function (Request $request) {
return User::query()
->when($request->query('q'), fn ($query, string $search) => $query
->where('name', 'like', "%{$search}%"))
->paginate($request->integer('per_page', 25))
->through(fn (User $user) => [
'value' => $user->id,
'label' => $user->name,
'description' => $user->email,
])
->toArray();
});The next_page_url value drives infinite loading. Length-aware paginator responses use the next numeric page:
{
"current_page": 1,
"data": [
{
"value": 1,
"label": "Mara Finch",
"description": "Senior editor",
"avatar": "https://example.com/mara.jpg"
}
],
"per_page": 25,
"total": 128,
"last_page": 6,
"next_page_url": "https://app.test/api/users?page=2"
}Cursor paginator responses may use next_cursor:
{
"data": [
{
"value": 1,
"label": "Mara Finch"
}
],
"per_page": 25,
"next_cursor": "eyJpZCI6NDJ9",
"next_page_url": "https://app.test/api/users?cursor=eyJpZCI6NDJ9"
}Existing endpoints may return an alternate pagination shape with data plus meta.next_page and meta.has_more:
{
"data": [
{
"value": 1,
"label": "Mara Finch"
}
],
"meta": {
"current_page": 1,
"per_page": 25,
"total": 128,
"next_page": 2,
"has_more": true
}
}Endpoints without pagination may return a bare array of items, but it disables infinite loading because no pagination metadata is available.
Selected lookup endpoints receive the configured valuesParam() key and should return the currently selected rows:
Route::get('/api/users/selected', function (Request $request) {
return User::query()
->whereIn('id', Arr::wrap($request->input('values', [])))
->get()
->map(fn (User $user) => [
'value' => $user->id,
'label' => $user->name,
'description' => $user->email,
]);
});Item Fields
Each item in a response may contain these keys:
| Key | Description |
|---|---|
value | Submitted value. Required. |
label | Visible label. Required. |
description | Secondary row text. |
disabled | Prevents selecting the item. |
disabledReason | Explains why a disabled item is unavailable. |
image | First-choice media shown in option rows or selected values. |
avatar | Fallback media used when image is not present. |
icon | Final media fallback. Requires a frontend icon resolver. |
badge | Trailing badge text. |
metadata | Extra application data. It isn't rendered. |
To group items, return entries with a label and an options array of items in place of plain items.
Validation
Finite options automatically add Rule::in() validation. Multiple choices and tokens add array validation and validate each item against the finite list, unless custom values or remote sources make the complete list unknown.
Membership validation doesn't require a value. To require a selection in the request, add the required method. For an optional field whose empty submitted values should pass, add the nullable method:
Combobox::make('country')
->options(['us' => 'United States', 'ca' => 'Canada']);
// Adds Rule::in(['us', 'ca'])
Combobox::make('topics')
->tokens()
->options(['Planning', 'Research'])
->allowCustomValues(false);
// Adds 'array' on topics and Rule::in([...]) on topics.*
Combobox::make('author_id')
->records()
->source('/api/users')
->exists(User::class, 'id');
// Adds an exists rule for the submitted record id.The minSelected and maxSelected methods validate the number of selections for multiple choices, tokens, and records. Multiple record fields add a distinct rule to each submitted ID by default. To allow duplicate record IDs, use distinct(false):
Combobox::make('reviewer_ids')
->records()
->source('/api/users')
->multiple()
->distinct(false);Membership Validation
Membership validation is on by default and resolves in this order:
| Option source | Generated rule |
|---|---|
| Array, collection, or closure options | Rule::in() over the resolved values |
| Eloquent model or builder with a column-backed value | A scoped membership query against the same builder |
| Eloquent model or builder with a computed, mapped, or dotted value | Rule::in() over the resolved option values |
source() or searchOptionsUsing() | None. No finite list exists on the server |
allowCustomValues() or ruleIn(false) | None. You opted out |
Computed and mapped values resolve the option list during validation. For large queries, use a column-backed optionValue to keep validation scoped to the query.
Remote options don't expose a finite list on the server. Inertia Forms logs a warning unless you validate the value with exists() or a custom membership rule, or acknowledge the omission with ruleIn(false):
Combobox::make('author_id')
->records()
->source('/api/users')
->exists(User::class, 'id');To accept values beyond the configured options, use ruleIn(false). It disables the automatic finite or Eloquent membership validation, so add explicit rules for the accepted value shape:
Combobox::make('status')
->options([
'draft' => 'Draft',
'published' => 'Published',
])
->ruleIn(false)
->rules(['string']);Shared APIs
The Combobox field covers finite choices, typed tokens, and record picking. In PHP, the tokens() and records() methods select the frontend intent, and ordinary choices keep the default intent.
Combobox also supports the shared field APIs documented in Form Class, Model Binding, Validation, Styling, Conditional Visibility, and Authorization.
Vue Display Slots
To build a custom option UI in Vue, you may replace the listbox rows, selected token chips, and status rows using slots:
<Combobox v-bind="form.getField('workspace_tool')">
<template #option="{ option, selected, disabled }">
<div :class="{ 'opacity-50': disabled }">
<strong>{{ option.label }}</strong>
<span v-if="option.description">{{ option.description }}</span>
<span v-if="selected">Selected</span>
</div>
</template>
<template #tag="{ option, remove, disabled }">
<span>
{{ option.label }}
<button v-if="!disabled" type="button" @click="remove(option.value)">
Remove
</button>
</span>
</template>
<template #empty="{ message }">
<span>{{ message }}</span>
</template>
<template #loading="{ message }">
<span>{{ message }}</span>
</template>
<template #create-option="{ message, create }">
<button type="button" @click="create">{{ message }}</button>
</template>
</Combobox>The option slot receives { option, selected, disabled }. The tag slot receives { option, remove, disabled }. The empty slot receives { query, message }, the loading slot receives { message }, and the create-option slot receives { query, message, create }.
Using the Component Directly
Combobox is exported from each stack's components subpath. The component accepts the same intent model as serialized PHP fields. In token mode, the standalone component also accepts the direct-only delimiters and transformTag props. Native attributes and listeners are forwarded to the native select in simple mode, and to the text input in custom mode. See Native Attributes and Events.
<script setup lang="ts">
import { Combobox } from '@inertiaui/form-vue/components'
import { ref } from 'vue'
const status = ref('review')
const topics = ref(['Research'])
const authorId = ref<number | null>(2)
const statusOptions = [
{ value: 'draft', label: 'Draft' },
{ value: 'review', label: 'In review' },
]
const topicOptions = [
{ value: 'Planning', label: 'Planning' },
{ value: 'Research', label: 'Research' },
]
const authors = [
{ value: 1, label: 'Mara Finch', avatar: '/avatars/mara-finch.jpeg' },
{ value: 2, label: 'Noel Park', avatar: '/avatars/noel-park.jpeg' },
{ value: 3, label: 'Iris Vale', avatar: '/avatars/iris-vale.jpeg' },
{ value: 4, label: 'Avery Stone', avatar: '/avatars/avery-stone.jpeg' },
]
</script>
<template>
<Combobox v-model="status" name="status" label="Status" :options="statusOptions" />
<Combobox
v-model="topics"
intent="tokens"
name="topics"
label="Topics"
:options="topicOptions"
:delimiters="[',', ';']"
transform-tag="uppercase"
/>
<Combobox
v-model="authorId"
intent="records"
name="author_id"
label="Author"
:options="authors"
:selected="[authors[1]]"
selected-record-media
/>
</template>import { Combobox } from '@inertiaui/form-react/components'
import { useState } from 'react'
const statusOptions = [
{ value: 'draft', label: 'Draft' },
{ value: 'review', label: 'In review' },
]
const topicOptions = [
{ value: 'Planning', label: 'Planning' },
{ value: 'Research', label: 'Research' },
]
const authors = [
{ value: 1, label: 'Mara Finch', avatar: '/avatars/mara-finch.jpeg' },
{ value: 2, label: 'Noel Park', avatar: '/avatars/noel-park.jpeg' },
{ value: 3, label: 'Iris Vale', avatar: '/avatars/iris-vale.jpeg' },
{ value: 4, label: 'Avery Stone', avatar: '/avatars/avery-stone.jpeg' },
]
export function DirectComboboxes() {
const [status, setStatus] = useState('review')
const [topics, setTopics] = useState(['Research'])
const [authorId, setAuthorId] = useState<number | null>(2)
return (
<>
<Combobox name="status" label="Status" options={statusOptions} value={status} onValueChange={(value) => setStatus(value as string)} />
<Combobox
intent="tokens"
name="topics"
label="Topics"
options={topicOptions}
delimiters={[',', ';']}
transformTag="uppercase"
value={topics}
onValueChange={(value) => setTopics(value as string[])}
/>
<Combobox
intent="records"
name="author_id"
label="Author"
options={authors}
selected={[authors[1]]}
selectedRecordMedia
value={authorId}
onValueChange={(value) => setAuthorId(value as number | null)}
/>
</>
)
}