Skip to content

    Browse components

    Expand Search

    A round search button that stretches into a field on press, focuses itself, pops in a clear button as you type, and folds back on Escape or when it loses focus empty.

    Open
    Customize

    right
    left

    Installation

    npx shadcn@latest add @glint-ui/expand-search

    First time using @glint-ui? Add the registry to components.json once, or install by URL: npx shadcn@latest add https://glintui.vercel.app/r/expand-search.json

    Usage

    import { ExpandSearch } from "@/components/ui/expand-search";
    
    <ExpandSearch onSearch={(q) => router.push(`/search?q=${q}`)} />

    Props

    PropTypeDefaultDescription
    widthnumber260Width in px when open.
    placeholderstring"Search…"Placeholder text.
    align"right" | "left""right"Which side stays put while it grows.
    onSearchReactNode—(query) => void, called on Enter.
    onChangeReactNode—(query) => void, called on every keystroke.
    classNamestring—Extra classes for the root element.