Forms & Inputs
Search Input
A search field with a leading magnifier and a focus-restoring clear button.
A search field with a leading magnifier and a clear button that appears once there is something to clear.
Import
tsx
1import { SearchInput } from "@yuhuanowo/yunui";Usage
Controlled: value is a string and onChange receives the next string, not an event — so filtering a list is a one-liner. Clearing calls onChange("") and returns focus to the field, so the next keystroke lands where the user expects instead of going nowhere.
Search input
- Button
- Badge
- Breadcrumb
- Card
- Checkbox
- Combobox
- Dialog
Sizes
size="sm" tightens the height and pulls the magnifier in — for toolbars and table headers where a full-height field would dominate.
Sizes
Notes
- It renders
type="text"withrole="searchbox", nottype="search". A native search input adds its own clear (×) decoration, which would sit right on top of this component's button. - When you don't pass an
aria-label, theplaceholderbecomes the accessible name — so the field is never nameless, and an explicit label still wins. - Set
clearable={false}when the field must always hold a value.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| clearable | boolean | true | Show a clear (×) button while there's a value. |
| clearLabel | string | — | Accessible label for the clear button (English default). |
| onChange | ((value: string) => void) | — | Called with the new query string — also called with `""` when cleared. |
| size | "sm" | "md" | md | Field size — `sm` for toolbars/dropdowns, `md` standalone. |
| value | string | — | Current query (controlled). |