SearchInput
Search input over InputGroup: a search icon, a built-in clear button that
appears once the field has a value, and an optional keyboard-shortcut hint
shown while it's empty. Pass suggestions for an animated "Try: …"
placeholder that cycles while the field is empty.
Import from "@desk/ui/components/search-input".
Usage
import { SearchInput, SearchInputProps } from "@desk/ui/components/search-input";Best practices
Use
SearchInputfor search/filter fields — it supplies the search icon, a clear button, and (viashortcutHint) aKbdhint; don't rebuild these on a plainInput.onChangereceives the next string on every keystroke and on clear (not a DOM event) — passvaluefor controlled use ordefaultValuefor uncontrolled.Pass cycling placeholder ideas via
suggestions(which suppresses the staticplaceholder);shortcutHintshows only while empty and is swapped for the clear button once the field has a value.Pill (
radius="full") at the 48pxxldefault is the search signature — mirrors mb3'sSearchInputField, which is pill at every size — so leave both defaults alone in standard search/filter placements; passsizeexplicitly for compact embedded contexts (popovers, table headers).
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| size | ResponsiveSize | "xl" | Size of the search input, its icon, and its clear button — a single token
or a per-breakpoint object like |
| radius | "rounded" | "square" | "full" | Border radius style. | |
| hasError | boolean | Show error styling. | |
| value | string | Controlled value. Omit to let SearchInput manage its own state. | |
| defaultValue | string | Initial value when uncontrolled. | |
| onChange | (value: string) => void | Called with the next value on every keystroke and on clear. | |
| onClear | () => void | Called when the built-in clear button is pressed. | |
| shortcutHint | string | Keyboard shortcut hint (e.g. "⌘K") rendered as a | |
| suggestions | readonly string[] | Cycling placeholder suggestions, animated over the field while it is empty
(e.g. | |
| suggestionPrefix | string | "Try:" | Static prefix shown before each cycling suggestion. |
| suggestionIntervalMs | number | 5000 | Rotation interval for the suggestions in ms. |
| testId | string | Test ID for testing. |
Also exports
- type
SearchInputProps
Composition
Builds on