Search field
A text field for searching. A clear button once there is text, Escape to clear, a shortcut that focuses it from anywhere, a spinner while results come and a count of what it found.
npx shadcn add https://kinoui.com/r/search-field.jsonCopy install command
Examples
Default
Press / to search. Pass loading while results come: the icon turns into a spinner once a search lasts 200ms, and count says how many it found.
Kino AO
CtrlK
Widen
Short in a toolbar, it widens into the room it is given while it is in use. Press Mod K to try it.
- AOAmara OkaforLead
- KWKenji WatanabeEngineer
- LFLucía FernándezDesigner
- TLTobias LindqvistProduct
Count
The count rolls to each new number and a screen reader hears it. countLabel says it in your words.
In a dialog
Escape clears the field first and closes the dialog only once the field is empty.
Installation
Copy code
npx shadcn@latest add https://kinoui.com/r/search-field.json- Files
lib/refs.tslib/reduce-motion.tscomponents/kino/input.tsxcomponents/kino/textarea.tsxlib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/input-group.tsxlib/keys.tsxcomponents/kino/kbd.tsxlib/number-format.tslib/roll.tsxcomponents/kino/search-field.tsx- Packages
@base-ui/reactclass-variance-authority- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
Props
Data attributes
CSS variables
Accessibility
- The field is a searchbox. Give it an
aria-labelor aFieldLabelthat names what it searches, and wrap the search in a<search>element. - Escape clears the text and stops there, so a dialog around the field stays open; with the field empty, Escape closes the dialog as usual.
- The clear button is out of the tab order, as the browser’s own is, because Escape already clears; a screen reader still reaches it as “Clear search”. Pressing it keeps focus in the field, and ⌘Z or Ctrl Z brings the text back.
- The shortcut is announced through
aria-keyshortcuts, and its keys are hidden from screen readers. - The count is read from a status line that is there before the first search, so every new count is heard.