Ballmac UI home

Search Field

A compact search control with a clear action, Enter callback, and preserved keyboard focus.

Installation

$ pnpm dlx shadcn@latest add @ballmac/search-field

Usage

import { SearchField } from "@/components/ballmac/search-field"

The full example is in the Code tab above.

Examples

States and variants

API reference

PropTypeDefault
value

Controlled search query.

string—
defaultValue

Initial query when uncontrolled.

string""
onValueChange

Called whenever the query changes or clears.

(value: string) => void—
onSearch

Called when Enter submits the query.

(value: string) => void—
label

Accessible name of the search field.

string—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
EnterSubmits the current query
Tab / SpaceClears the query and returns focus

Use with AI

A compact search control with a clear action, Enter callback, and preserved keyboard focus. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Search Field (@ballmac/search-field) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Filter a list or catalog
  • Submit a query from a toolbar

Not for

  • Use spotlight-search for site-wide command search

Registry JSON: https://ui.ballmac.com/r/search-field.json

Credits

Free to use in personal and commercial projects.