How to build an accessible Search in React

Renders a native <input type="search"> associated with a <label> (defaulting from the i18n catalog) so the field is announced as a searchbox; the clear control is a labeled <button> and moves focus back to the input after clearing.

When to use a Search

When not to use it

Keyboard interactions

Role searchbox, verified at WCAG 2.2-AA.

Common mistakes

Avoid: <Input placeholder="Search" onChange={(e) => runQuery(e.target.value)} />

Prefer: <Search onSearch={(q) => runQuery(q)} debounceMs={300} />

Search provides type="search" semantics, a magnifier affordance, a clear button, and built-in debouncing so you avoid firing a query on every keystroke

Example

<Search onSearch={(q) => runQuery(q)} />

See the full Search reference →