A search button that grows into a field. Read the text with onValueChange.
header-search.tsx
ExpandingSearch
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | — | The text, when the parent owns it. |
| default | string | "" | The first text, when the field owns it. Default "". |
| on | — | Each change of the text, at once (each key, a clear). | |
| on | — | Run the search: on Enter, on a clear (with ""), and after debounce ms of no typing. | |
| on | — | The text was cleared (the clear button, or Escape with text). | |
| debounce | number | — | Ms of no typing before onSearch runs. undefined (the default): typing does not search, only Enter and a clear do. 0: each change searches. |
| shortcut | false"/""mod+k" | — | The key that focuses and selects the field from anywhere. Default false (none). |
| class | string | — | Classes of the frame (the InputGroup), for its width. The classes of the root. Its width is the open width (default w-60 max-w-full). |
| busy | boolean | — | The field waits for results: the spinner takes the place of the search icon, and the input is aria-busy. |
| size | "default""lg""sm""xs" | "default" | |
| variant | "dashed""default" | — | |
| open | boolean | — | The field is open (controlled). It also stays open while it holds text. |
| default | boolean | false | The field starts open (uncontrolled). Default false. |
| on | — | The field opened or closed. | |
| align | "end""start" | "start" | The side that stays put while the field grows: start (default) or end, for a header. |
| labels | — | The words: trigger, and the Search Field words clear and loading. Keep it stable. | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
| EnterorSpace | On the round button: opens the field and moves the focus into it. |
|---|---|
| Escape | Clears the text. On an empty field: closes it and puts the focus on the button. |
| / | Opens the field when shortcut is /. |
Built with
Installs with Expanding Search
- Components
- Search Field











