Duolith docs

SearchField

A rounded search box with a search icon and a clear button, inside a search landmark.

Stability: experimental

Props

PropTypeDefaultMeans
labelstringThe accessible name of the landmark and the field; the placeholder when none is given.
valuestringbindable("")The text. Bind it with bind:value={name}.
placeholderstringHint text while empty.
disabledbooleanfalseCannot be edited or focused.
onSubmit(value: string) => voidRuns with the text when Enter is pressed. The page never reloads.

States

StateLooks like
focusedThe surface turns from raised to surface, with a primary border and ring.
has textThe clear button shows at the end.
disabled50% opacity, no clear button.

Accessibility

rolesearch landmark (a form with role search) holding a searchbox
nameThe label prop, on both.
focusTab reaches the field. The clear button is left out of the Tab order: Escape clears from the keyboard.
keyboardEnter 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} />