DitherCharts

Search input

Updated

SearchInput is a search field in the input group's ink frame, with a pixel magnifier. ⌘K (or Ctrl+K) anywhere on the page focuses it, shown as a key hint while it's empty, and a Clear button takes the hint's place once there's a query. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

import "@/components/dithercharts/controls.css"
import { SearchInput } from "@/components/dithercharts/search-input"

<SearchInput label="Search charts" placeholder="Revenue, churn…" onValueChange={(query) => setQuery(query)} />
<SearchInput label="Filter series" shortcut={false} />

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add search-input

Props

It renders a native element, so every other attribute that element takes passes through.

SearchInput props
PropTypeDefaultDescription
labelrequiredType ReactNodeDefault –The caption above the field, and its accessible name.
valueType stringDefault –The query, for a controlled field; pair it with onValueChange.
defaultValueType stringDefault ""The query at first, for an uncontrolled field.
onValueChangeType (value: string) => voidDefault –Called with the query as it's typed or cleared.
shortcutType booleanDefault true⌘K (or Ctrl+K) anywhere on the page focuses the field, shown as a key hint while it's empty.
hintType ReactNodeDefault –Help text under the field, read after its label.
errorType ReactNodeDefault –An error under the field; it also marks the field invalid.