Combobox

入力に合わせて選択肢のリストを絞り込むテキストフィールド。グループ、空の状態、チップによる複数選択、WAI-ARIA コンボボックスのキー操作に対応し、フォームコントロールとして使えます。

対応フレームワーク
  • Angular: 対応
  • Vue: 対応
  • React: 対応
  • React Native: 対応

使い方

LisbonTokyo

インポート

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

API リファレンス

SoneComboboxComponentコンポーネント

`<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.

セレクター
sone-combobox
入力
名前型 デフォルト
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
value双方向

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

SoneComboboxValuenull
search双方向

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

string""
open双方向

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`

SoneComboboxInputDirectiveディレクティブ

`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`.

セレクター
input[soneComboboxInput]
エクスポート名
soneComboboxInput
入力
名前型 デフォルト
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
open双方向

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

booleanfalse
keepOpenOnOutsideClick

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

booleanfalse
soneComboboxInputSoneOverlayContent | nullnull