Morphing Search Chip Search

A docked, glass-style search bar that springs wider on focus and unfolds a recent-searches and suggestions panel from its own edge. Typed terms become removable filter chips that the bar grows around, and suggestions filter live as the user types.

Morphing Search Chip Search
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme from registry.json
See how it was built

Installation

pnpm dlx shadcn@latest add @beui/morphing-search-chips

Requires @beui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { MorphingSearchChips } from "@/components/motion/morphing-search-chips";export function Example() {  return (    <MorphingSearchChips      suggestions={["Design", "Engineering", "Marketing"]}      storageKey="search-recents"    />  );}
  • Building a search field inside a header, hero or toolbar that should feel like a floating glass control rather than a plain input.
  • Filtering a list or catalog with multiple removable tag-style filters entered as free text.
  • Showing recent searches and live suggestions that open from the search bar itself.
  • Needing a search bar that is keyboard accessible as a combobox with chip removal via Backspace and Delete.

Examples

Controlled filters with a server-filtered suggestion list

Keeps chips and query in parent state and disables client-side filtering because suggestions already arrive filtered from the server.

controlled-filters-with-a-server-filtered-suggestion-list.tsx
import { useState } from "react";import { MorphingSearchChips } from "@/components/motion/morphing-search-chips";export function ProductSearch({ results }: { results: string[] }) {  const [chips, setChips] = useState<string[]>([]);  const [query, setQuery] = useState("");  return (    <MorphingSearchChips      chips={chips}      onChipsChange={setChips}      query={query}      onQueryChange={setQuery}      suggestions={results}      filter={false}      loading={false}      maxChips={5}      placeholder="Search products"      label="Search products"    />  );}

Bottom-opening search with persisted recents and form submission

Opens the panel below the bar, stores recent searches in localStorage, and submits chips as repeated form fields.

bottom-opening-search-with-persisted-recents-and-form-submission.tsx
import { MorphingSearchChips } from "@/components/motion/morphing-search-chips";export function SiteSearch() {  return (    <form action="/search" method="get">      <MorphingSearchChips        side="bottom"        storageKey="site-search-recents"        maxRecents={8}        suggestions={["Changelog", "Pricing", "Docs"]}        name="filter"        normalize={(term) => term.trim().slice(0, 40) || null}        emptyState={<p>Try a topic or a product name.</p>}      />    </form>  );}

With trailing filter actions

Adds a trailing control inside the bar using the actions prop and a loading indicator for async suggestions.

with-trailing-filter-actions.tsx
import { SlidersHorizontal } from "lucide-react";import { MorphingSearchChips } from "@/components/motion/morphing-search-chips";export function ToolbarSearch({ loading }: { loading: boolean }) {  return (    <MorphingSearchChips      loading={loading}      side="auto"      actions={        <button type="button" aria-label="Open filters" className="grid size-9 place-items-center rounded-full">          <SlidersHorizontal className="size-4" />        </button>      }    />  );}

API reference

PropTypeDefaultDescription
chipsstring[]—Controlled active filter chips shown inside the bar.
defaultChipsstring[][]Initial chips when uncontrolled.
onChipsChange(chips: string[]) => void—Called when chips are added or removed.
querystring—Controlled text in the field.
defaultQuerystring""Initial field text when uncontrolled.
onQueryChange(query: string) => void—Called when the field text changes.
recentsstring[]—Controlled recent searches, newest first.
defaultRecentsstring[][]Initial recent searches when uncontrolled.
onRecentsChange(recents: string[]) => void—Called when recent searches change.
storageKeystring—Persists uncontrolled recents in localStorage under this key.
maxRecentsnumber5How many recent searches to keep.
suggestionsstring[][]Terms offered while typing.
filter((term: string, query: string) => boolean) | falsecase-insensitive substringHow suggestions match the query. Pass false when suggestions are already filtered, e.g. from a server.
maxSuggestionsnumber6How many matches to list under the typed query.
loadingbooleanfalseShows a Searching indicator and marks the list busy.
maxChipsnumber—Maximum number of chips allowed at once.
normalize(term: string) => string | null—Cleans a term before it becomes a chip; return null to reject it.
emptyStateReactNode—Shown when the field is empty and there are no recent searches.
side"top" | "bottom" | "auto""top"Direction the panel grows. auto grows up unless there is no room above.
openboolean—Controlled open state of the panel.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => void—Called when the panel opens or closes.
disabledbooleanfalseDisables the input, chip removal buttons and opening the panel.
namestring—Submits each chip as a hidden input with this name.
placeholderstring"Search"Placeholder text of the field.
labelstring"Search"Accessible name for the search field.
actionsReactNode—Trailing controls rendered inside the bar, such as filter buttons.
classNamestring—Extra classes merged onto the root element.

Accessibility

  • The field is a text input with role combobox, aria-autocomplete list, aria-expanded reflecting panel state, and aria-controls pointing to the listbox when rows exist.
  • Highlighted rows are referenced via aria-activedescendant; options are role option with aria-selected and never take focus.
  • Keyboard: ArrowDown/ArrowUp move the highlight, Enter adds the highlighted term as a chip, Escape clears the query first and then closes the panel, Delete removes the highlighted recent search.
  • Backspace at the start of the field marks the last chip, and a second Backspace removes it; ArrowLeft/ArrowRight (mirrored in RTL) step between chips.
  • A polite aria-live region announces added, removed and limit messages; a visually hidden hint describes keyboard shortcuts and is linked via aria-describedby.
  • Each chip's remove button has an aria-label naming the filter; the decorative panel glass is aria-hidden.
  • Respects prefers-reduced-motion by replacing springs with short fades and disabling layout animation and smooth scrolling.
  • The list is labelled Suggestions or Recent searches; the loading indicator is decorative icon plus visible text Searching.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Morphing Search Chip Search" component (beui/morphing-search-chips) from its shadcn registry.1. Install it with: npx shadcn@latest add @beui/morphing-search-chips2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: chips, defaultChips, onChipsChange, query, defaultQuery, onQueryChange, recents, defaultRecents, onRecentsChange, storageKey, maxRecents, suggestions, filter, maxSuggestions, loading, maxChips, normalize, emptyState, side, open, defaultOpen, onOpenChange, disabled, name, placeholder, label, actions, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { MorphingSearchChips } from "@/components/motion/morphing-search-chips";export function Example() {  return (    <MorphingSearchChips      suggestions={["Design", "Engineering", "Marketing"]}      storageKey="search-recents"    />  );}```

Files & dependencies

  • components/motion/morphing-search-chips.tsx→ @components/motion/morphing-search-chips.tsx
  • lib/ease.ts→ @lib/ease.ts
  • lib/hooks/use-controllable.ts→ @lib/hooks/use-controllable.ts
  • lib/hooks/use-dismiss.ts→ @lib/hooks/use-dismiss.ts
  • lib/hooks/use-on-open.ts→ @lib/hooks/use-on-open.ts
  • lib/hooks/use-row-cursor.ts→ @lib/hooks/use-row-cursor.ts
  • lib/i18n.tsx→ @lib/i18n.tsx
  • lib/presence-gate.tsx→ @lib/presence-gate.tsx
  • lib/utils.ts→ @lib/utils.ts
  • lib/layers.ts→ @lib/layers.ts
dependenciesclsxlucide-reactmotiontailwind-merge
registryDependencieshttps://beui.dev/r/theme.json

Looks similar, elsewhere