Combobox

Um campo de texto que filtra uma lista de opções enquanto você digita, com grupos, estado vazio, seleção múltipla como chips e as teclas de combobox do WAI-ARIA, como controle de formulário.

Disponível em
  • Angular: disponível
  • Vue: disponível
  • React: disponível
  • React Native: disponível

Uso

LisbonTokyo

Importação

ts
import {
  SoneComboboxComponent,
  SoneComboboxInputDirective,
} from "@surface-one/angular/combobox";

Referência da API

SoneComboboxComponentComponente

`<sone-combobox>` — a text field that filters a listbox of options as you type (shadcn/ui Combobox, spartan/ui Autocomplete; the WAI-ARIA combobox pattern). Up / Down, Home / End and PageUp / PageDown move the highlight (`aria-activedescendant`), Enter picks, Escape closes. `options` holds `{ value, label, disabled, keywords }` or labelled groups of them; `[(value)]` is one value or, with `multiple`, a list shown as removable chips (Backspace removes the last). `[(search)]` is the typed text.

Seletor
sone-combobox
Inputs
NomeTipo Padrão
options

The options: `{ value, label, disabled?, keywords? }`, or `{ label, options }` groups.

SoneComboboxItems[]
multiple

Pick several options, shown as chips; `value` is then a list.

booleanfalse
valuebidirecional

The picked value (`null` while none), or a list with `multiple` — `[(value)]`.

SoneComboboxValuenull
searchbidirecional

The typed text — `[(search)]`; it clears when the popup closes.

string""
openbidirecional

The popup is open — `[(open)]`.

booleanfalse
shouldFilter

Filter the options by `search`. Turn off when the options come filtered from a server.

booleantrue
filter

A custom match function (default `soneCommandFilter`: every word, accent-insensitive).

SoneCommandFiltersoneCommandFilter
placeholderstring""
emptyText

Shown in the popup when no option matches.

—$localize`:Combobox empty state:No results found.`
clearable

A clear button while something is picked.

booleanfalse
disabledbooleanfalse
invalidbooleanfalse
inputId

The input's `id`, for a `<label for>`.

string | nullnull
namestring | nullnull
ariaLabel

Names the input when no `<label>` does.

string | nullnull
ariaDescribedby

Extra ids for the input's `aria-describedby`.

string | nullnull
clearLabel—$localize`:Combobox clear button:Clear selection`

SoneComboboxInputDirectiveDiretiva

`input[soneComboboxInput]` — the combobox's text field and the trigger of its listbox popup, on the popover family's overlay (`SoneOverlayTriggerBase`): the popup renders on `<body>` next to the whole control, closes on Escape and on a click outside, and focus never leaves the input. Used by `sone-combobox`.

Seletor
input[soneComboboxInput]
Exportado como
soneComboboxInput
Inputs
NomeTipo Padrão
side

The side of the trigger the panel opens on; it flips when that side lacks room.

FloatingSide"bottom"
align

Alignment along the trigger's edge.

FloatingAlign"start"
offset

Gap between the trigger and the panel, in px.

number4
openbidirecional

Shown or not — `[(open)]`.

booleanfalse
keepOpenOnOutsideClick

Keep the panel open on a click outside it (Escape still closes it).

booleanfalse
soneComboboxInputSoneOverlayContent | nullnull