UI.MD

Search Trigger

A header button drawn as a compact field that opens search or a command palette, with its shortcut shown as a keycap.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/search-trigger.json

Usage

import { SearchTrigger } from "@/components/ui/search-trigger"

Examples

Default

Opens your search on click; the shortcut is only shown, so listen for the same keys yourself.

Wider, with its own label

Children replace the label. Give it a width and the keycap stays at the end.

API Reference

PropTypeDefaultDescription
shortcutReact.ReactNode-The keys that open the same search, shown in a Kbd: "⌘K". Hidden on touch screens. Shown only; the keyboard listener is yours.
childrenReact.ReactNode"Search..."The label.
...propsReact.ComponentProps<"button">-Every button prop, including onClick.
shortcutReact.ReactNodeThe keys that open the same search, shown in a Kbd: "⌘K". Hidden on touch screens. Shown only; the keyboard listener is yours.
childrenReact.ReactNode = "Search..."The label.
...propsReact.ComponentProps<"button">Every button prop, including onClick.