Animated Search Input

A search field with rotating example searches, an icon that opens into a field, and text that drifts away when sent.

PROGet Animated Search Input and 168 other Pro components with pro lifetime — Get Pro

Category
Forms
Access
Pro
Source
291 lines · one file
States
6 drawn

The decision inside it

The examples never become the name

The field is always called Search for screen readers; the rotating examples are drawn under it and hidden, so nobody hears a new label every three seconds.

When to use it

Use Animated Search Input for a prominent search on a landing page, docs or an app header, where example searches teach what can be found. For a search inside a form or a filter bar, use the plain Input.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Animated Search Input for this.
Install it: npx shadcn@latest add @liro/animated-search-input
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/animated-search-input.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/doc-search.tsx
import { AnimatedSearchInput } from "@/components/ui/animated-search-input";

export function DocSearch({ search }: { search: (q: string) => void }) {
  return (
    <AnimatedSearchInput
      placeholders={["Search contracts…", "Try “unsigned this week”", "Search by signer"]}
      onSubmit={search}
      shortcut="mod+k"
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
placeholdersstring[] NoExample searches that take turns as the placeholder.
intervalnumber NoMilliseconds each example shows. Default 3000.
expandableboolean NoStart as an icon button that opens into the field. Default false.
vanishOnSubmitboolean NoBlur the sent text up and away, then clear. Default true.
valuestring No–
defaultValuestring No–
onValueChange(value: string) => void No–
onSubmit(value: string) => void NoCalled with the trimmed text on Enter or the send button.
shortcutstring NoA key that focuses it from anywhere, e.g. "mod+k" or "/".
widthnumber NoWidth when open, in pixels. Default fills its parent.

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Rotating examples
  • Typing
  • Sent
  • Icon
  • Opened by shortcut
  • Reduced motion

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances