Morphing Search

A search field or icon that morphs into a panel of results.

Preview

"use client";

import { Blocks, BookOpen, Bot, FolderOpen, Palette } from "lucide-react";
import {
  MorphingSearch,
  type MorphingSearchItem,
} from "@/components/motion/morphing-search";

const ITEMS: MorphingSearchItem[] = [
  {
    id: "project-folder",
    title: "Project Folder",
    description: "Block · Files and previews",
    keywords: ["files", "overlay"],
    icon: FolderOpen,
  },
  {
    id: "motion-components",
    title: "Motion components",
    description: "Collection · Interaction primitives",
    keywords: ["animation", "components"],
    icon: Blocks,
  },
  {
    id: "agent-interfaces",
    title: "Agent interfaces",
    description: "Collection · AI building blocks",
    keywords: ["ai", "chat"],
    icon: Bot,
  },
  {
    id: "installation",
    title: "Installation guide",
    description: "Documentation · Add your first component",
    keywords: ["setup", "shadcn"],
    icon: BookOpen,
  },
  {
    id: "design-tokens",
    title: "Design tokens",
    description: "Documentation · Color, type, and motion",
    keywords: ["theme", "styles"],
    icon: Palette,
  },
];

export function MorphingSearchPreview() {
  return (
    <div className="flex w-full max-w-[22rem] items-center gap-3">
      <MorphingSearch items={ITEMS} placeholder="Find components" />
      <MorphingSearch
        items={ITEMS}
        placeholder="Find components"
        shortcut=""
        iconOnly
      />
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/morphing-search

API Reference

items
MorphingSearchItem[]

Searchable items, matched on title, description and keywords.

Default—
placeholder?
string

Input placeholder and accessible name. Default: "Search"

Default—
shortcut?
string

Opens the search when this key is pressed outside a text field. Default: "f"

Defaultf
iconOnly?
boolean

Render the closed trigger as a compact search icon.

Defaultfalse
emptyMessage?
string

Text shown when no item matches the query. Default: "No results found."

Default—
open?
boolean

Whether the search panel is open, for controlled use.

Default—
defaultOpen?
boolean

Whether the panel starts open when uncontrolled. Default: false

Defaultfalse
onOpenChange?
((open: boolean) => void)

Called with the new open state when the panel opens or closes.

Default—
onQueryChange?
((query: string) => void)

Called with the query text as the user types.

Default—
onSelect?
((item: MorphingSearchItem) => void)

Called with the chosen item after its own `onSelect`, then the panel closes.

Default—
labels?
Partial<{ placeholder: string; empty: string; close: string; dialog: string; results: string; }>

Override any built-in string.

Default—
className?
string

Classes merged onto the closed trigger wrapper.

Default—

More in Morphing Search

Keep in mind

Some components on this site are inspired by or recreated from existing work across the web. I'm not here to take credit; just to learn, experiment, and sometimes push things a bit further. If something looks familiar and I forgot to mention you, reach out and I'll fix that right away.

Updated