Search field
The search bar's 56px pill as a search box that filters a page, a list or a table in place, with a clear button. It never opens a search view.
import { SearchField } from '@windmorph/react';Keyboard
| Key | Action | Where |
|---|---|---|
| Tab or Shift + Tab | Moves focus to the input, then the clear button (while there is text) and any trailing icon button. | |
| Escape | Clears the query. With the input already empty, Escape reaches what holds the field, such as a dialog, which can close.In the input | In the input |
| Enter | Calls onSubmit with the query. It waits while an input method is composing.In the input | In the input |
| Enter or Space | Clears the query and moves focus back to the input.On the clear button | On the clear button |
- Typing, a press and Arrow Down open nothing: the field filters in place.
- Moving through what it filters is up to that content, such as a
List.
Screen reader
- Role
- The input is a
searchbox(type="search"). Nothing pops up, so it has noaria-expandedoraria-haspopup. - Accessible name
- The field's
aria-labeloraria-labelledbynames the input, which the types require. The placeholder is not the name.aria-describedby,aria-detailsandaria-controlsgo to the input too. - States announced
- Disabled (
disabledon the input).
- The clear button is named by
labels.clear("Clear search"). - Say when nothing matches in a
role="status"region of your own, so screen readers hear it.
Focus
- Keyboard focus in the input draws the 3px
secondaryfocus ring inside the pill; pointer presses show no ring. - A press on the pill around the input (its padding or the leading icon) puts the caret in the input. A press on the clear button keeps focus, and a phone's keyboard, in the input.
- With
autoFocusthe input takes focus as the field mounts.
Touch target
- The field is 56px tall (44px at density -3), and the leading and trailing slots are 48 × 48px, as tall as the field allows.
- The clear button and any trailing icon buttons are
standardIconButtons with their own 48 × 48px touch targets, 8px apart so they meet without overlapping.
Motion
None. The field has no motion of its own; its icon buttons keep their state layers.
What you need to do
- Name the field with
aria-labeloraria-labelledby, matching the placeholder ("Search settings"). - Point
aria-controlsat what the field filters, and announce "No results" in arole="status"region. - Give every icon-only button in
leadingIconandtrailingIconanaria-label.