ui-kit0.0

Signature

Expanding search

An icon that grows into a search field.

When to use

  • Toolbars and headers where search is secondary and space is tight.
  • When you want the field to take over the row only while it is in use.
  • If search is the main task of the page, show a normal Input with a search icon instead.

API

ExpandingSearch

PropTypeDefaultDescription
value / defaultValue / onValueChangestring—The query, controlled or uncontrolled.
open / defaultOpen / onOpenChangebooleanfalseExpanded state, controlled or uncontrolled.
placeholderstring'Search'Input placeholder.
labelstring'Search'Accessible name of the button and the field.
widthnumber | string280Expanded width (px or any CSS length). Never wider than the viewport minus 32px.
size'sm' | 'md' | 'lg''md'Height 32 / 36 / 44px.
shortcutbooleanfalsePress ⌘K (Ctrl K elsewhere) to expand and focus. Shows a hint while empty.
onSubmit(value: string) => void—Enter pressed in the field.
resultsReactNode—Panel under the field while it is open and has a query.

The results panel is positioned absolutely under the field, so keep the component out of ancestors with overflow: hidden.

Keyboard

KeyAction
Enter / SpaceOn the icon: expands and focuses the field.
⌘K / Ctrl KWith shortcut: expands and focuses from anywhere.
EnterIn the field: onSubmit.
EscClears the query, collapses and returns focus to the icon.

Accessibility

  • The wrapper is a search landmark. The icon button has an accessible name and aria-expanded.
  • The input is hidden from the tab order and the accessibility tree until the field is open, and focus moves into it when it opens.
  • It folds back on blur only when empty, so a typed query is never lost; Tab out with text and it stays open.
  • The input is type="search" with the browser’s own clear control replaced by a consistent Clear button.

Motion

  • Width: a CSS transition on --ui-spring-smooth (540ms, never overshoots) between the square icon button (36px) and the expanded width.
  • The input fades in 90ms after the field starts to grow, and stays mounted until the fold-back has finished so it never pops out.
  • The results panel enters with the soft rise (380ms, 4px, blur clearing) and leaves faster (160ms).
  • Reduced motion: the field opens and closes instantly; focus and results still behave the same.