Skip to Content
⭐️ Leave a star →
ComponentsSearch

Search

Search input with a dropdown results list. Keyboard navigation with Arrow keys, Enter to select, Escape to close. Supports loading state and empty state.

Features

Keyboard navigation with Arrow keys, Enter, and Escape.
Loading state support via data-loading.
Empty state rendering.
Debounced search with configurable delay.

Example

import { Search } from '@wire-ui/react' <Search.Root value={query} onSearchChange={setQuery} onSelect={(option) => alert('Selected: ' + option.title)}> <Search.Input placeholder="Search frameworks..." /> <Search.Content> {filtered.map((item) => ( <Search.Item key={item.id} option={item}> {item.title} </Search.Item> ))} </Search.Content> </Search.Root>

Styling

Search exposes data-loading on Root and data-highlighted on items for keyboard navigation state.

<Search.Root className=" data-[loading]:opacity-50 "> <Search.Input className="border border-black" /> <Search.Item className=" data-[highlighted]:bg-gray-100 " /> </Search.Root>

Using data attributes

Root sets data-loading when the loading prop is true. Items set data-highlighted when focused via keyboard.

/* Loading state */ [data-loading] { opacity: 0.6; } /* Keyboard-highlighted item */ [data-highlighted] { background: #f5f5f5; }

Root props

PropTypeDefaultDescription
onSearchChange(query: string) => voidCalled on every keystroke
onSelect(option: SearchOption) => voidCalled when an item is selected
loadingbooleanfalseAdds data-loading to root
searchDelaynumber0Debounce delay for onSearchChange in ms

SearchOption type

type SearchOption = { id: string | number title: string subtitle?: string }

Item data attributes

AttributeWhen present
data-highlightedItem is keyboard-focused / active

Root data attributes

AttributeWhen present
data-loadingloading prop is true

Keyboard navigation

KeyAction
ArrowDownMove highlight down
ArrowUpMove highlight up
EnterSelect highlighted item
EscapeClose dropdown, clear highlight

Keyboard Interactions

KeyDescription
ArrowDownMoves highlight to the next result item.
ArrowUpMoves highlight to the previous result item.
EnterSelects the highlighted item.
EscapeCloses the dropdown and clears the highlight.
Last updated on

MIT License © 2026 wire-ui

Search – Wire UI