Skip to contentKino
Skip to Content

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.json
Share on

Examples

Issues

Kino · Mobile app
KN-142
Checkout fails on saved cards
MC
KN-139
Checkout timeout on slow networks
TA
KN-137
Checkout button disabled after a coupon
PR
KN-131
Card declined message is unclear
JL
KN-128
Billing address not saved on the second step
MC
KN-124
Export to CSV drops the time zone
PR
KN-121
Export to PDF cuts the last row
TA
KN-117
Onboarding email sent twice
JL
KN-112
Onboarding checklist stuck at 80%
MC
KN-108
Mobile nav covers the search field
PR

Recent:

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

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

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

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Props

PropTypeDefaultDescription
variant'default''widen''default'Widen sits at --search-field-width while it is empty and left, and widens to its room while it is in use.
shortcutstring[]NoneKeys that focus the field from anywhere on the page, as ['Mod', 'K'] or ['/'], shown at its end until the person types, except on a touch screen. A key that types, such as /, still types in other fields, and nothing happens while a dialog covers the field.
loadingbooleanfalseResults are on their way. The icon turns into a spinner once it lasts 200ms, and stays at least 300ms.
countnumberNoneHow many results the search found, shown while there is text and read out in a status line. Leave it out while there is no search.
countLabel(count: number) => string“24 results”What the count says. Only its number rolls.
onClear() => voidNoneCalled once the clear button or Escape has emptied the field, after onValueChange.

Data attributes

AttributeOnDescription
data-filledSearchFieldPresent while the field holds text.
data-wideSearchFieldPresent while a widen field is in use or holds text.

CSS variables

VariableSet it onDefaultDescription
--search-field-widthSearchField, or anything above it15remHow wide a widen field is while it is empty and left.

Accessibility

  • The field is a searchbox. Give it an aria-label or a FieldLabel that 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.