Skip to content

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

Search field keyboard
KeyAction
Tab or Shift + TabMoves focus to the input, then the clear button (while there is text) and any trailing icon button.
EscapeClears the query. With the input already empty, Escape reaches what holds the field, such as a dialog, which can close.In the input
EnterCalls onSubmit with the query. It waits while an input method is composing.In the input
Enter or SpaceClears the query and moves focus back to the input.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 no aria-expanded or aria-haspopup.
Accessible name
The field's aria-label or aria-labelledby names the input, which the types require. The placeholder is not the name. aria-describedby, aria-details and aria-controls go to the input too.
States announced
Disabled (disabled on 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 secondary focus 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 autoFocus the 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 standard IconButtons 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-label or aria-labelledby, matching the placeholder ("Search settings").
  • Point aria-controls at what the field filters, and announce "No results" in a role="status" region.
  • Give every icon-only button in leadingIcon and trailingIcon an aria-label.