A heading with a bracketed word: press it and the brackets close on the word, fuse into a pill and open into the search field, with a rolling result count.
Click meTap me
Workspace admin guides
bracket-snap, lively
Use Bracket Snap when a page's heading is also its search: a help center, an internal handbook, an admin home, a card whose title filters its list. At rest it is typography; pressing the bracketed word turns the brackets into a real search field with no modal. For a search that must always be visible (a dense toolbar), use a regular input or a command menu.
pnpm dlx shadcn@latest add @motionkit-pro/bracket-snapnpx shadcn@latest add @motionkit-pro/bracket-snapyarn dlx shadcn@latest add @motionkit-pro/bracket-snapbunx --bun shadcn@latest add @motionkit-pro/bracket-snapRequires a Pro license and the @motionkit-pro registry with your token. See Installation.
import { BracketSnap } from "@/components/ui/bracket-snap"
export function HelpHeading() {
const [query, setQuery] = useState("")
const results = articles.filter((a) => a.title.toLowerCase().includes(query.toLowerCase()))
return (
<BracketSnap
className="text-5xl"
placeholder="anything"
fieldLabel="Search the help center"
controls="results"
value={query}
onValueChange={setQuery}
resultCount={results.length}
>
Find
</BracketSnap>
)
}The heading's font size sets the scale of the brackets. Presets: hero (default, field up to 620 px, / and ⌘K open it), inline (field up to 320 px, no shortcut) and sticky (stays open on blur). fieldMax, hotkey and closeOnBlur override the preset. temperament changes motion intensity only. Pass resultCount and the open capsule shows the count of the current query at its right end: its digits roll on every keystroke (up when results grow, down when they shrink), so the consequence of typing is read inside the field. The text never runs under it (its width is reserved), resultLabel names the unit ("guides", "members") and is hidden when the field is narrower than 300 px, and loading turns the count into a spinner while results are on their way. Custom bracket shapes are not supported: the brackets are drawn by the component and scale with the heading's font size.
Prop
Type
Also accepts all props of Omit<
HTMLAttributes<HTMLHeadingElement>,
"children" | "defaultValue" | "onChange"
>.
The inline preset: the card's title filters its list and the capsule counts the members left.
Click meTap me
5 members · Northwind workspace
bracket-snap, lively
The sticky preset: Enter searches, the count waits on the index with loading, and the query stays when focus leaves.
Click meTap me
Engineering handbook
Recently updated
bracket-snap, lively
input type="search" at once; keys typed during the animation are kept. With controls the field is a combobox linked to the results list.aria-hidden SVG.status region ("3 results"); the rolling digits are aria-hidden. With loading the field is aria-busy and "Searching…" is announced.| Key | Action |
|---|---|
| Enter / Space | On the word: opens the field and focuses it |
| / or ⌘K / Ctrl K | Opens the field (hero, sticky) |
| Enter | In the field: onSearch |
| Escape | Clears the text, then closes and refocuses the word |
The brackets and the word fade out and the finished field fades in in place, and the reverse on close. The count's digits swap with a short crossfade instead of rolling and the loading spinner holds still.
requestAnimationFrame loop runs while the brackets move and stops at rest.ResizeObserver, never per frame.Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom.
click, press, a keyboard shortcut, typing
No charge, pinch or growth: the brackets and the word fade out and the finished field fades in in place (and the reverse on close). The result count swaps with a short crossfade and the loading spinner is static.
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)