Skip to main content

SearchField

A search input with a leading icon and a clear button; Escape clears.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

A search input with a leading icon and a clear button; Escape clears.

Accessibility​

Always render a visible <label> (the label prop wires htmlFor/id for you). Errors set aria-invalid and are announced via aria-describedby. Required fields expose aria-required.

Install and import​

npx shadcn@latest add @prism/search-field
import { SearchField } from '@/components/prism/SearchField';

In a no-build prototype, read it from the bundle instead: const { SearchField } = window.PrismDesignSystem_39d121;

Props​

PropTypeRequiredDescription
labelstring—
valuestring—
defaultValuestring—
placeholderstring—
onChange(value: string) =&gt; void—
onClear() =&gt; void—
clearLabelstring—Accessible name of the clear button. Default "Clear search"; change it if the page has its own control with that name.
isDisabledboolean—
width"xs" | "sm" | "md" | "lg" | "full"—Maximum width of the box: "xs" | "sm" | "md" | "lg" (default, 36rem) | "full". Still shrinks on a phone. Sizes are the --field-width-* tokens.
actionsReact.ReactNode—Buttons beside the box (a Search submit, "Show all"); they wrap under it on a phone.
onSubmit(value: string, event: React.FormEvent&lt;HTMLFormElement&gt;) =&gt; void—Makes the bar a <form role="search">: Enter or a type="submit" button calls this (the browser's submit is prevented).
searchLabelstring—Names the search landmark when the page has more than one (aria-label on the bar).
classNamestring—