SearchInput

A round button that grows into a field on a spring. Inputs.

Open playground

About

SearchInput is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { SearchInput } from "@ashutoshswamy/smoui" and set placeholder, width, defaultOpen among its 7 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { SearchInput } from "@ashutoshswamy/smoui";

<SearchInput placeholder="Search" onChange={(q) => setQuery(q)} />

Props 7

placeholder

Field placeholder.

stringdefault "Search"
width

Open width: px, or any CSS length such as "100%".

numberstringdefault 280
defaultOpen

Start expanded.

booleandefault false
collapsible

Set false for an always-open field, like a header search.

booleandefault true
shortcut

A key hint shown while the field is empty, e.g. "/". Hidden on touch screens.

string
ref

Opens the field if folded and focuses it.

{ focus(): void }
onChange / onSubmit

Escape or an empty blur folds it back.

(value: string) => void