SearchField
A rounded search box with a search icon and a clear button, inside a search landmark.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | The accessible name of the landmark and the field; the placeholder when none is given. | |
value | string | bindable("") | The text. Bind it with bind:value={name}. |
placeholder | string | Hint text while empty. | |
disabled | boolean | false | Cannot be edited or focused. |
onSubmit | (value: string) => void | Runs with the text when Enter is pressed. The page never reloads. |
States
| State | Looks like |
|---|---|
focused | The surface turns from raised to surface, with a primary border and ring. |
has text | The clear button shows at the end. |
disabled | 50% opacity, no clear button. |
Accessibility
| role | search landmark (a form with role search) holding a searchbox |
| name | The label prop, on both. |
| focus | Tab reaches the field. The clear button is left out of the Tab order: Escape clears from the keyboard. |
| keyboard | Enter submits; Escape empties the field. |
Theme tokens
color.raised color.surface color.primary color.border color.muted space.2 space.3 radius.full
Example
<SearchField label="Search places" bind:value={query} onSubmit={search} />