SearchField
A search editor with clear and cancel affordances.
- Native host
- Liquid Glass on iOS 26
- New in 0.1
import { SearchField, searchFieldPrimitive } from "nitro-ui-sdk/search-field";- HeroUI Native
- SearchField
- Expo UI
- SearchBarDockedSearchBar

Light 
Dark 
Liquid Glass
On this page
SearchField pairs a native Search keyboard action with clear and optional cancel buttons. Use the glass variant for a floating search control over content.
Anatomy
import { SearchField } from "nitro-ui-sdk/search-field";
<SearchField.Root label="Catalog" clearLabel="Clear search" cancelLabel="Cancel">
<SearchField.Surface>
<SearchField.SearchIcon />
<SearchField.Input />
<SearchField.ClearButton />
</SearchField.Surface>
<SearchField.CancelButton />
</SearchField.Root>;
| Part | Description |
|---|---|
Root |
Owns the query and search actions. |
Surface |
Field chrome or floating glass. |
SearchIcon |
Decorative magnifying glass. |
Input |
Native search editor. |
ClearButton |
Visible while enabled and nonempty. |
CancelButton |
Optional action outside the field surface. |
Usage
import { SearchField } from "nitro-ui-sdk/search-field";
<SearchField.Root label="Catalog" placeholder="Search products" clearLabel="Clear search" />;
Variants and sizes
Use filled (default) for an inline search editor or glass for a floating pill. Both support sm, md and lg.
States
The focused editor uses the focus border. Invalid fields use the danger border. Disabled fields reduce opacity and reject editing actions and glass touch feedback. The clear action appears for a nonempty enabled query. Cancel dismisses editing after the clear is accepted. A prevented or refused clear keeps focus.
Controlled
Pass defaultValue for a local value or value with onValueChange to own it. The editor reconciles to the owner’s value after each edit, including a declined request.
import { useState } from "react";
import { SearchField } from "nitro-ui-sdk/search-field";
export function Example() {
const [value, setValue] = useState("");
return <SearchField.Root label="Catalog" clearLabel="Clear search" value={value} onValueChange={setValue} />;
}
Liquid Glass
The glass variant uses MaterialView on supported iOS versions when glass is enabled and Reduce Transparency is off. Otherwise it uses the opaque secondary surface. Reduced Motion disables the native material animation.
Props
SearchField.Root
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string |
Required | Localized name spoken by assistive technology. |
hint |
string |
— | Additional instructions spoken with the field. |
error |
string |
— | Validation message spoken with the field. |
invalid |
boolean |
false |
Applies the invalid appearance. A nonempty error also marks it invalid. |
disabled |
boolean |
false |
Disables editing and reduces opacity. |
variant |
SearchFieldVariant |
"filled" |
Inline or floating appearance. |
size |
SearchFieldSize |
"md" |
Field size. |
clearLabel |
string |
Required | Localized clear button name. |
cancelLabel |
string |
— | Shows an optional cancel button with this name. |
onCancel |
(details: ActionDetails) => void |
— | Runs before clearing and dismissing. May prevent the default action. |
value |
string |
— | Owner-controlled text. |
defaultValue |
string |
"" |
Initial text in uncontrolled mode. |
onValueChange |
(value: string, details: ActionDetails) => void |
— | Receives the requested text. Call details.preventDefault() to decline. |
onValueCommit |
(value: string, details: ActionDetails) => void |
— | Runs once per accepted edit that changes the value. |
placeholder |
string |
— | Native placeholder. |
keyboard |
TextKeyboard |
"default" |
Native keyboard layout. |
contentType |
TextContentType |
— | Autofill hint, such as "email" or "username". |
autocapitalize |
TextCapitalization |
"none" |
Capitalization mode. |
autocorrect |
boolean |
false |
Use OS autocorrection. |
maxLength |
number |
— | Maximum number of UTF-16 code units. |
onSubmit |
(value: string, details: ActionDetails) => void |
— | Receives the committed text on Return or submit. |
styles |
PartStyles<SearchFieldPart, SearchFieldVariant, SearchFieldSize, SearchFieldState> |
— | Style resolvers keyed by part. |
api |
Controller<SearchFieldActions> |
— | Attach a controller created with the primitive. |
agentId |
string |
— | Identity for replacing a field in a reused view. |
children |
ReactNode |
— | Compound anatomy override. |
SearchField.Surface and SearchField.SearchIcon
| Prop | Type | Default | Description |
|---|---|---|---|
part |
SearchFieldPart |
— | Override the style key for this part. |
children |
ReactNode |
— | Content to render inside this part. |
SearchField.Input, SearchField.ClearButton and SearchField.CancelButton
| Prop | Type | Default | Description |
|---|---|---|---|
part |
SearchFieldPart |
— | Override the style key for this part. |
Controller API
import { SearchField, searchFieldPrimitive } from "nitro-ui-sdk/search-field";
const api = searchFieldPrimitive.createApi();
const field = <SearchField.Root label="Catalog" clearLabel="Clear search" api={api} />;
// Use api.current after the field mounts.
export { field, api };
| Action | Signature | Result |
|---|---|---|
focus |
(source?: ActionSource) => ActionStatus |
Focuses the editor when it is available. |
blur |
(source?: ActionSource) => ActionStatus |
Dismisses native editing. |
setValue |
(value: string, source?: ActionSource) => ChangeStatus |
Requests a new value. |
clear |
(source?: ActionSource) => ChangeStatus |
Requests an empty value. |
submit |
(source?: ActionSource) => ActionStatus |
Calls the submit handler with the current text. |
cancel |
(source?: ActionSource) => ChangeStatus |
Requests a clear. Editing is dismissed when the clear is accepted. |
Controlled edits return requested while the owner renders. Agent calls resolve after that commit.
Styles
import { SearchField } from "nitro-ui-sdk/search-field";
<SearchField.Root label="Catalog" clearLabel="Clear search" styles={{ icon: ({ tokens }) => ({ text: { color: tokens.colors.accent } }) }} />;
Resolvers receive tokens, variant, size, and state. State includes disabled, invalid, focused, and empty.
Accessibility
The native editor speaks label as its name and reads error before hint. Editing, selection and dictation are platform-owned. UIKit exposes the search trait. The clear and cancel buttons each have a separate spoken name.
Agent API
| Action | Arguments | Notes |
|---|---|---|
focus |
None | Focus the editor. |
setValue |
String | Request a value. Controlled owners can decline. |
clear |
None | Request an empty value. |
submit |
None | Available when onSubmit is set. |
cancel |
None | Available when cancelLabel is supplied. |
Platform notes
| iOS | Android | |
|---|---|---|
| Implementation | UIKit editor with the Search return key and optional Liquid Glass surface. | Android EditText with the IME Search action and an opaque surface. |
| Verification | Native iOS harness in the example app. | Kotlin is written for Android. The Android NDK is unavailable on this machine, so no Android build was run. |