「空き時間グリッド」は Pro に含まれます。解除するとプレビューが表示されます。
仕組み
The text in the field is the query. Matching tries a plain substring first, then letters in order ("nyk" finds New York), and ranks contiguous runs higher. On close the field returns to the chosen label, so a half-typed query never stands in for a value. The panel is not portaled, so it stays put inside dialogs and scroll areas.
向いている場面
- Choosing one value from a long list people know by name: a city, a person, a project.
- When typing is faster than scrolling, on desktop and mobile alike.
向かない場面
- Under eight options: use a select or radio group.
- Several values: use a multi-select or tags input.
- Running commands: use a command palette.
使い方
import { useState } from 'react'
import { Combobox } from './Combobox.jsx'
const cities = [
{ value: 'lis', label: 'Lisbon', description: 'UTC+0' },
{ value: 'sgp', label: 'Singapore', description: 'UTC+8' },
{ value: 'tyo', label: 'Tokyo', description: 'UTC+9' },
]
export function ZoneField() {
const [zone, setZone] = useState(null)
return (
<>
<label htmlFor="zone">Time zone</label>
<Combobox id="zone" options={cities} value={zone} onChange={setZone} placeholder="Search a city" />
</>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
options | { value, label, description?, disabled? }[] | — | The options; value must be unique. label is what is matched and shown in the field. |
value | string | number | null | — | Controlled value; null means nothing chosen. |
defaultValue | string | number | null | null | Initial value when uncontrolled. |
onChange | (value, option) => void | — | Called when an option is chosen, or with nulls when Esc clears a closed field. |
placeholder | string | 'Search' | Hint in the empty field. |
renderOption | (option) => ReactNode | — | Leading content for each row, such as an avatar or badge. |
emptyText | string | — | Text when nothing matches; defaults to labels.noMatch. |
disabled | boolean | false | Disables the field. |
invalid | boolean | false | Danger outline and aria-invalid. |
labels | object | — | Replaces built-in text: noMatch, results(n), toggle. |
...rest | HTMLAttributes<HTMLDivElement> | — | Go to the root; id and aria-label / labelledby / describedby go to the input. List height: --ds-combo-list-height (248px); layer: --ds-combo-z (30). |
アクセシビリティ
- Follows the ARIA 1.2 combobox pattern with list autocomplete: the input has role="combobox", aria-expanded, aria-controls and aria-activedescendant; the list is a listbox with aria-selected options.
- Keyboard: Down / Up open and move (skipping disabled rows), Alt+Up closes, Home / End jump when not searching, Enter chooses, Esc closes or, when closed, clears, Tab closes.
- The number of results is announced in a polite live region while searching.
- Matches are shown by weight and a tint, not colour alone. Rows are 40px, 44px on touch. Reduced motion removes the panel and check animations.
モーション
The panel enters in 220ms ease-out from 6px above and scale 0.96. The field turns white with a halo over 220ms; the chevron turns in 240ms. The check on the chosen row pops with a 320ms spring.
プロジェクトに追加
プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。
Combobox.jsxcombobox.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。
同じカテゴリ
フォーム入力「図形のブール演算」は Pro に含まれます。解除するとプレビューが表示されます。
「カスケード選択」は Pro に含まれます。解除するとプレビューが表示されます。





