Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

SearchField

  • Stable
  • WCAG 2.2 evidence
  • RTL
  • Web · iOS · Android

Search input. Built on React Aria SearchField: the input has the searchbox role, Escape clears it, Enter calls onSubmit, and once it holds text a clear button appears (named "Clear search", translated by React Aria) that empties the field and keeps focus in it (WCAG 2.1.1, 4.1.2). Focus draws the brand border and halo (2.4.7); paste and autofill are never blocked (3.3.7, 3.3.8). Consumer duties: an accessible name (visible label or aria-label, for example "Search"); announcing the number of results (for example with announceStatus, WCAG 4.1.3); registering the shortcut that shortcut advertises.

import { SearchField } from "@nexera-ui/react";
Loading example…
5
examples
39
props
7
live controls
3
platforms
10
WCAG criteria
6
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
description
placeholder
platform
isDisabled
isReadOnly
isRequired
isInvalid
Generated code
import { SearchField } from "@nexera-ui/react";

<SearchField />

Examples 4

The same examples as Storybook, rendered live. Open Code to copy one.

Platforms

Figma Platform: Web (40 px, border), iOS (36 pt grey pill; the pointer target is 44 pt) and Android (56 dp round bar with the navigation button and the account avatar as leadingAction / trailingAction).

Loading example…

States

With a value the clear button replaces the shortcut hint; Escape clears too. Disabled and read-only have no clear button.

Loading example…

Long label

Long labels and helper texts wrap; the value scrolls inside the box.

Loading example…

Right to left

Right-to-left: the glyph moves to the right and the clear button to the left.

Loading example…

Props 39

Press "Try it" on a card to load that prop into the playground.

39 props shown

descriptionNexera
ReactNode

Helper text under the field, linked with aria-describedby. Shown when provided.

Default –
errorMessageNexera
ReactNode | ((validation: ValidationResult) => ReactNode)

Error text under the field, shown with an icon while the field is invalid and linked with aria-describedby. A function receives React Aria's validation result. Defaults to the browser's validation message.

Default –
placeholderNexera
string

Hint shown while the field is empty, for example "Search people, teams, requests". Never the label.

Default –
platformNexera
"web" | "ios" | "android"

Platform look. Defaults to the NexeraProvider platform.

Default "web"
shortcutNexera
ReactNode

Keyboard shortcut hint shown at the end of the empty field on web. Visual only (hidden from assistive technology): register the shortcut in your app and describe it with aria-keyshortcuts.

Default –
aria-keyshortcutsNexera
string

Shortcut that focuses the field, in ARIA syntax ("Control+K"), set on the input as aria-keyshortcuts.

Default –
leadingActionNexera
ReactNode

Interactive element in place of the search glyph, for example an IconButton that opens the navigation. It must carry its own accessible name; the search glyph is shown when this is not set.

Default –
trailingActionNexera
ReactNode

Interactive element after the value, for example an account button with its own name.

Default –
clearLabelNexera
string

Accessible name of the clear button. React Aria provides it translated ("Clear search"); set it only to change the wording.

Default –
inputRefNexera
Ref<HTMLInputElement>

Ref to the native <input> (the root ref points to the field wrapper).

Default –
classNameNexera
string

Extra classes for the root, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style of the root.

Default –
labelNexera
FieldLabelContent

Visible label, linked to the control by React Aria (WCAG 1.3.1, 3.3.2). Short noun, for example "Work email". Wraps instead of truncating. A placeholder is never a substitute for it. Not set: the field has no visible label. Not set: the field has no visible label of its own.

Default –
aria-labelNexera
string

Accessible name when it must differ from the visible label. Prefer the visible label (WCAG 2.5.3). Accessible name. Required when there is no visible label; translate it. Accessible name. Optional when aria-labelledby is set.

Default –
aria-labelledbyNexera
string

Id(s) of element(s) that name the field; wins over the visible label. Id(s) of element(s) that name the field; wins over aria-label. Id(s) of visible element(s) that name the field.

Default –
validationBehaviorReact Aria
"native" | "aria"

Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.

Default 'native'
typeReact Aria
"search" | "text" | "url" | "tel" | "email" | "password" | (string & {})

The type of input to render. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).

Default 'search'
enterKeyHintReact Aria
"search" | "enter" | "done" | "go" | "next" | "previous" | "send"

An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).

Default –
isDisabledReact Aria
boolean

Whether the input is disabled.

Default –
isReadOnlyReact Aria
boolean

Whether the input can be selected but not changed by the user.

Default –
isRequiredReact Aria
boolean

Whether user input is required on the input before form submission.

Default –
isInvalidReact Aria
boolean

Whether the input value is invalid.

Default –
validateReact Aria
(value: string) => true | ValidationError | null

A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if validationBehavior="native". For realtime validation, use the isInvalid prop instead.

Default –
autoFocusReact Aria
boolean

Whether the element should receive focus on render.

Default –
valueReact Aria
string

The current value (controlled).

Default –
defaultValueReact Aria
string

The default value (uncontrolled).

Default –
onChangeReact Aria
(value: string) => void

Handler that is called when the value changes.

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

Default –
idReact Aria
string

The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

Default –
autoCompleteReact Aria
string

Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).

Default –
maxLengthReact Aria
number

The maximum number of characters supported by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefmaxlength).

Default –
minLengthReact Aria
number

The minimum number of characters required by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefminlength).

Default –
patternReact Aria
string

Regex pattern that the value of the input must match to be valid. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefpattern).

Default –
inputModeReact Aria
"search" | "text" | "url" | "tel" | "email" | "none" | "numeric" | "decimal"

Hints at the type of data that might be entered by the user while editing the element or its contents. See [MDN](https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute).

Default –
autoCorrectReact Aria
string

An attribute that takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocomplete).

Default –
spellCheckReact Aria
string

An enumerated attribute that defines whether the element may be checked for spelling errors. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).

Default –
nameReact Aria
string

The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).

Default –
formReact Aria
string

The <form> element to associate the input with. The value of this attribute must be the id of a <form> in the same document. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).

Default –
onSubmitReact Aria
(value: string) => void

Handler that is called when the SearchField is submitted.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

7 direct · 3 supporting
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.11Non-text ContrastLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 2.4.7Focus VisibleLevel AA · supporting test
  • 2.5.8Target Size (Minimum)Level AA · supporting test
  • 3.3.1Error IdentificationLevel A · tested directly
  • 3.3.2Labels or InstructionsLevel A · tested directly
  • 3.3.7Redundant EntryLevel A · tested directly
  • 3.3.8Accessible Authentication (Minimum)Level AA · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

  • data-hovered
  • data-pressed
Usage
<SearchField className="data-hovered:opacity-90 shadow-sm" />

Used in blocks

Related components