Components Forms
SearchInput
StableA search field with a clear button, Escape to clear and an optional shortcut hint.
Use SearchInput to filter lists and tables or to start a search. It is a native search input (role searchbox) with a leading icon, a clear button once there is text, and a keyboard hint while empty. Pair with SearchableList or FilterBar for complete filtering patterns.
Overview
/
import { SearchInput } from '@bindshq/stance-react';
export function Basic() {
return (
<div style={{ width: '100%', maxWidth: 360 }}>
<SearchInput aria-label="Search templates" placeholder="Search templates" shortcut="/" />
</div>
);
}Light, dark and high contrast
Every Stance component is designed and tested in all three appearance modes.
/
/
/
Import
import { SearchInput } from '@bindshq/stance-react';Platforms
SearchInput has native counterparts. They share Stance tokens and intent, and use each platform’s own controls and conventions. The live previews on this page are the web implementation.
import { SearchInput } from '@bindshq/stance-react';Examples
5 users
- Priya Raman
- Tom Okafor
- Lena Fischer
- Marco Bianchi
- Aiko Tanaka
import * as React from 'react';
import { SearchInput } from '@bindshq/stance-react';
const users = ['Priya Raman', 'Tom Okafor', 'Lena Fischer', 'Marco Bianchi', 'Aiko Tanaka'];
export function Filtering() {
const [query, setQuery] = React.useState('');
const results = users.filter((u) => u.toLowerCase().includes(query.toLowerCase()));
return (
<div style={{ display: 'grid', gap: 12, width: '100%', maxWidth: 360 }}>
<SearchInput
aria-label="Search organisation users"
placeholder="Search users"
value={query}
onValueChange={setQuery}
/>
<p role="status" style={{ margin: 0, fontSize: 13 }}>
{results.length} {results.length === 1 ? 'user' : 'users'}
</p>
<ul style={{ margin: 0, paddingLeft: 18, fontSize: 14 }}>
{results.map((u) => (
<li key={u}>{u}</li>
))}
</ul>
</div>
);
}⌘K
import { SearchInput } from '@bindshq/stance-react';
export function Loading() {
return (
<div style={{ display: 'grid', gap: 12, width: '100%', maxWidth: 360 }}>
<SearchInput size="sm" aria-label="Search (small)" defaultValue="NDA" />
<SearchInput aria-label="Search contracts" defaultValue="Master services" loading />
<SearchInput
size="lg"
aria-label="Search (large)"
placeholder="Search everything"
shortcut="⌘K"
/>
</div>
);
}API reference
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | None | Controlled value. |
defaultValue | string | '' | Initial value. |
onValueChange | (value: string) => void | None | Called on every change. |
onSearch | (value: string) => void | None | Called on Enter. |
onClear | () => void | None | Called when cleared by button or Escape. |
shortcut | string | None | Keyboard hint shown while empty, e.g. "⌘K". |
loading | boolean | false | Replace the search icon with a spinner. |
clearLabel | string | 'Clear search' | Clear button label. |
size | 'sm' | 'md' | 'lg' | 'md' | Control height. |
Accessibility
- Renders <input type="search">, exposed as a searchbox.
- Provide a label with aria-label or FormField; the placeholder is not a label.
- Clearing returns focus to the field so typing can continue.
- Announce result counts near the results with a live region (for example "12 templates").
Keyboard
| Keys | Action |
|---|---|
| Escape | Clears the value (when not empty). |
| Enter | Calls onSearch. |