Skip to content
esc

SearchField

Inputshadcn/ui

Search box: Input with a search icon, a clear button while it has text, Escape to clear and an optional shortcut hint. 52px by default, 40px with size='sm' for toolbars.

When to use

  • Give it an aria-label or a visible label that says what it searches: 'Search transactions'.
  • Filter as people type for local lists; debounce network searches.
  • Don't build a search box from Input plus an absolutely positioned icon; use SearchField.
  • Don't put a submit button next to it for instant filtering.

Accessibility

Role
searchbox
Keyboard
Escape clears the text. Tab reaches the clear button.
Notes
The icon is aria-hidden; the field needs aria-label or a label.

Props

  • value / onChange

    string / ChangeEventHandler

    Controlled like Input; or use defaultValue.

  • onClear

    () => void

    Called when the clear button or Escape empties it; set your value to '' here when controlled.

  • size= 'default'

    'default' | 'sm'

    Height.

  • shortcut

    string

    Hint such as '⌘K'.

Prompt for your agent

Use the UnbuiltUI SearchField. Call unbuilt_get_component("SearchField") first and follow its spec: variants, states, usage rules and accessibility.

unbuilt_get_component returns

2 variants3 states4 props4 usage rules3 a11y notes5 tokens1 example

Add it with shadcn

$npx shadcn add https://unbuiltui.com/r/search-field.json

Tokens · 5

bg.subtlefg.subtlefg.mutedborder.focusradius.md