Passer au contenu principal

SearchInput

Implemented

WAI-ARIA combobox with a grouped Top-N typeahead (SEARCH-04, ADR-049). The DS owns debounce, keyboard navigation (ArrowUp/Down, Enter, Escape), aria-activedescendant and the loading/empty/short-query states; the consumer supplies onSearch and receives grouped suggestions. Renders a real GET form, so search still works without JavaScript. ADR-071: the chromeless variant owns its field-level ring (`ring-offset-ep-bg`) as the blessed HeroSearch-style indicator; the boxed (non-chromeless) variant rings the input box itself — never nest either inside a parent focus-within ring.

Categorymolecules
Sourcecomponents/molecules/SearchInput/SearchInput.tsx
AI HintWAI-ARIA combobox with a grouped Top-N typeahead (ADR-049) — the sanctioned path-1 search field: compose it chromeless with leadingIcon for hero/sheet combobox rows. ADR-070: field rows use the overlay construction (pointer-events-none absolute icon over a full-width padded input) — never compose an icon as an inline sibling of an input; see docs/decisions/ADR-070-search-field-composition.md.

Catalog fallback

Live MDX preview not available for SearchInput. Showing component catalog metadata instead.

Props

Preview

SearchInput

Prop
Type
Required
Default
Description
label
string
Required
—

Accessible name and (sr-only) visible label of the combobox.

onSearch
(query: string) => Promise<SearchInputGroup[]>
Required
—

Called after debounce with the trimmed query once it reaches minChars. Groups are { id, label, options: { id, label, href? }[] }.

onSelect
(value: string, option: SearchInputOption) => void
Optional
—

Selection callback. The input is set to the option label; the consumer navigates or filters.

onSubmit
(query: string) => void
Optional
—

Form submit handler (Enter with no active option). When omitted, the native GET form navigates — the no-JS fallback.

name
string
Optional
"q"

GET parameter name of the fallback form.

action
string
Optional
—

GET action of the fallback form (defaults to the current URL).

debounceMs
number
Optional
300

Debounce before onSearch. 0 searches immediately (tests, pre-debounced consumers).

minChars
number
Optional
2

Minimum trimmed length before searching; shorter queries show shortQueryLabel.

value
string
Optional
—

Controlled value. Omit for an uncontrolled input.

onValueChange
(value: string) => void
Optional
—

Notified on every keystroke (before debounce).

placeholder
string
Optional
—

Input placeholder (the label remains the accessible name).

className
string
Optional
—

Utility class passthrough on the form wrapper (spacing/width only).

id
string
Optional
—

Input id override; the listbox and option ids derive from it.

shortQueryLabel
string
Optional
"Type at least 2 characters"

Copy shown while the query is shorter than minChars.

loadingLabel
string
Optional
"Searching…"

role=status copy while a search is in flight.

noResultsLabel
string
Optional
"No suggestions"

role=status copy when the resolved groups are empty.

renderForm
boolean
Optional
true

false renders a <div> instead of the <form role="search"> wrapper so the combobox can live inside a consumer form; Enter with no active option is then left to that outer form, which stays the no-JS GET fallback.

chromeless
boolean
Optional
false

Renders the input without its own frame or surface (hero flat field).

leadingIcon
React.ReactNode
Optional
—

Icon rendered inside the input's left edge (hero magnifier).

Quick use:<SearchInput />

Accessibility

ARIA rolecombobox

ARIA

1 rule

WAI-ARIA 1.2 combobox pattern

input role="combobox" with aria-expanded, aria-controls, aria-autocomplete="list" and aria-activedescendant

a11y

1 rule

WCAG 2.5.5 Target Size

options are role=option, grouped with role=group + aria-label, and at least 44px tall (WCAG 2.5.5)

progressive-enhancement

1 rule

SEARCH-04 no-JS fallback

renders <form role=search method=get> with a named input, so Enter searches without JavaScript

behaviour

1 rule

ADR-049

ArrowDown/ArrowUp wrap through the flattened options, Enter selects the active option, Escape closes without clearing the query

Design System v4.1.0 | ePassLive