Search Field
Search landmark built with definePrimitive: Enter runs onSearch, Escape clears only when there is text, and agents get a submit action.
Example
Press Enter to search, Escape to clear.
search-field-demo.tsxCopy code
Installation
Copy code
npm packages
lucide-reactUsage
ImportCopy code
API reference
SearchField
| Prop | Type | Default |
|---|---|---|
labelrequiredAccessible name for the search landmark and its input. | string | – |
clearLabel | string | "Clear search" |
value | string | – |
defaultValue | string | – |
onValueChange | InputProps["onValueChange"] | – |
onSearch | SearchFieldOptions["onSearch"] | – |
controller | ReturnType<typeof createInputController> | – |
placeholder | string | – |
name | string | – |
disabled | boolean | – |
className | string | – |
Other exports
searchFieldSearchFieldRoottype SearchFieldInputtype SearchFieldOptionstype SearchFieldPropsAccessibility
- A search landmark: Enter runs onSearch, Escape clears.
- Built with definePrimitive, since UI SDK has no search part.
Agent actions
Exposes a submit action to agents, only when onSearch is set.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.