Forms

Autocomplete

A text input that filters and selects from a list of suggestions as you type.

html
<UiAutocomplete :items="..." />

Items

required

items is the list of suggestions, filtered as you type. A bare string or number is the shorthand for an option whose label and value match; the long form is { label, value } with an optional icon and disabled. { type: 'label' } and { type: 'divider' } entries group a long list. Unlike Combobox, the trigger here *is* the text field, so what you type filters in place rather than in a separate search box.

Functionally close to Combobox, but the trigger itself is a free-typing text input (not just a filter box inside a popup) — useful when the typed text should also be a valid value, not just a filter.

Model value

modelValue is the selected value — the option's value, not the text currently typed, and an array once multiple is set. Pass it to control the selection yourself; the typed query is the component's own business and isn't exposed through this model.

Selected: nothing

Default value

defaultValue is what's selected on first render while the field still owns its own state — a sensible starting suggestion you don't otherwise need to hold onto.

Multiple

multiple lets more than one option be selected at once, and turns the selected set into removable tags inside the field. Each tag carries its own remove button; an item can still opt out of selection entirely with its own disabled flag.

Placeholder

placeholder is the hint in the field while nothing has been typed or selected. Say that typing filters — “Search a country” rather than “Country” — since this input behaves unlike the plain text fields around it.

Icon

icon sits at the start of the field while nothing is selected; an option carrying its own icon replaces it once chosen. It's a way to say what the field searches without spending a label on it.

Disabled

disabled locks the whole input — the field stops accepting text and the dropdown stops opening. It's separate from a per-item disabled, which greys out one option while leaving the rest usable.

Clearable

clearable shows a button to clear the current selection.

Variant

variant picks between the ringed outline field on the page background and the filled, ringless soft one, which has its own section below.

Content

content positions the dropdown relative to the field: which side it opens on, how it aligns to the trigger, and how far off it sits.

Open

open controls whether the suggestion list is showing. Pass it to drive the list from your own state and bind it with v-model:open so typing still opens it; omit it and the component manages that itself.

Default open

defaultOpen starts the suggestion list expanded on mount while leaving the open state uncontrolled — a way to show what's on offer before anyone types, at the cost of covering whatever sits below.

`variant="soft"`

A filled, tinted background with no ring.

Wrapped in `FormField`


API Reference

Generated from the component's source — props, slots and emits as the component actually declares them.

Props

Prop
Type
Default
Description
itemsrequired
AutocompleteItem[]
The list of selectable options, optionally grouped with label and divider items.
string | number | (string | number)[]
The selected value(s). Pass this to fully control the selection yourself.
string | number | (string | number)[]
The initial selected value(s) when uncontrolled.
boolean
false
Allows selecting more than one option.
string
Placeholder text shown in the search input when nothing is typed.
string
Icon displayed at the start of the input when no option is selected.
boolean
false
Disables the input, preventing interaction.
boolean
false
Shows a button to clear the current selection.
"outline" | "soft"
'outline'
The visual style of the input.
AutocompleteContentProps
{ align: 'start', side: 'bottom', sideOffset: 8 }
Positioning options for the dropdown list.
boolean
Controls whether the dropdown list is open. Omit to let the component manage its own open state.
boolean
false
Whether the dropdown list is open by default when uncontrolled.

Emits

Event
Payload
Description
update:modelValue
[value: string | number | (string | number)[] | undefined]
update:open
[value: boolean]

Types

ts
type AutocompleteItem = AutocompleteOption | AutocompleteLabelItem | AutocompleteDividerItem | string | number;
ts
interface AutocompleteOption {
    label: string;
    value: string | number;
    icon?: string;
    disabled?: boolean;
}
ts
interface AutocompleteLabelItem {
    type: "label";
    label: string;
}
ts
interface AutocompleteDividerItem {
    type: "devider" | "divider" | "separator";
}
ts
interface AutocompleteContentProps {
    align?: "start" | "center" | "end";
    side?: "bottom" | "top";
    sideOffset?: number;
}