GooseUI

Components

Search Panel

New

A flexible search component with 5 different search patterns. Choose the variant that best fits your use case: live instant search, command palette (⌘K), scoped search with filters, contextual suggestions, or federated multi-source search. It is a client component: React keeps the query and calls onQueryChange. The command palette is a native <dialog>, so Escape, the focus trap and the backdrop come from the browser. Icons are inline SVG, there are no dependencies besides React.

Browser Support

<dialog>

Displays the modal dialog

Your browser:
::backdrop

Styles the search dialog backdrop

Your browser:

Preview

Interactive demo showcasing all 5 search variants.

Popular
Recent searches

Installation

npx shadcn@latest add @gooseui/search-panel
pnpm dlx shadcn@latest add @gooseui/search-panel
yarn dlx shadcn@latest add @gooseui/search-panel
bunx --bun shadcn@latest add @gooseui/search-panel

Usage

import {
  SearchPanel,
  SearchPanelResults,
  SearchPanelSuggestions,
  SearchPanelFederated,
  SearchPanelCommands,
} from "@/components/ui/search-panel"

export default function MySearch() {
  const [results, setResults] = useState([])

  return (
    <SearchPanel
      variant="instant"
      placeholder="Search components..."
      onQueryChange={(query) => {
        // Fetch results based on query
        setResults(searchData(query))
      }}
    >
      <SearchPanelResults
        results={results}
        defaultResults={[
          { label: "Popular", items: [{ id: "1", title: "Button" }] },
          { label: "Recent", items: [{ id: "2", title: "carousel", query: "carousel" }] },
        ]}
        onSelect={(result) => console.log(result)}
      />
    </SearchPanel>
  )
}

Variants

1. Instant Search

Results appear as you type with configurable debounce. Best for quick lookups and autocomplete.

<SearchPanel variant="instant" debounce={150}>
  <SearchPanelResults results={results} />
</SearchPanel>

2. Command Palette

Modal search triggered by ⌘K (Ctrl+K). Supports both search and commands with > prefix.

<SearchPanel variant="command" placeholder="Search or type > for commands">
  <SearchPanelCommands
    commands={[
      { id: "theme", title: "Toggle theme", action: () => toggleTheme() },
      { id: "settings", title: "Open settings", shortcut: "⌘," },
    ]}
    results={results}
  />
</SearchPanel>

3. Scoped Search

Search with tabs/filters to narrow down results by category.

<SearchPanel
  variant="scoped"
  scopes={[
    { id: "all", label: "All" },
    { id: "docs", label: "Docs" },
    { id: "code", label: "Code" },
  ]}
  defaultScope="all"
>
  <SearchPanelResults results={filteredResults} />
</SearchPanel>

4. Contextual Suggestions

Shows recent searches, trending items, and personalized suggestions before typing.

<SearchPanel variant="contextual">
  <SearchPanelSuggestions
    recent={[{ id: "1", title: "carousel" }]}
    trending={[{ id: "2", title: "button" }]}
    suggested={[{ id: "3", title: "Based on your history..." }]}
  />
  <SearchPanelResults results={results} />
</SearchPanel>

5. Federated Search

Search across multiple sources simultaneously with grouped results.

<SearchPanel variant="federated">
  <SearchPanelFederated
    sources={[
      { id: "components", name: "Components", results: [...] },
      { id: "docs", name: "Documentation", results: [...] },
      { id: "github", name: "GitHub Issues", results: [...] },
    ]}
    onSelect={(result, source) => console.log(result, source)}
  />
</SearchPanel>

Props

SearchPanel

Props

PropTypeDefaultDescription
variant"instant" | "command" | "scoped" | "contextual" | "federated""instant"Search pattern variant
size"sm" | "md" | "lg" | "xl" | "full""md"Panel width
placeholderstring"Search..."Input placeholder text
debouncenumber150Debounce delay in ms (instant variant)
scopes{ id: string; label: string }[]-Available scopes (scoped variant)
onScopeChange(scope: string) => void-Callback when the active scope changes
onQueryChange(query: string) => void-Callback when search query changes
triggerLabelstring"Search..."Text of the command palette trigger
clearLabelstring"Clear search"Accessible name of the clear button
openboolean-Controlled open state of the command palette
onOpenChange(open: boolean) => void-Called when the command palette opens or closes
hotkeybooleantrueCmd/Ctrl+K toggles the palette, false leaves the shortcut to you
triggerReactNode | null-Replaces the built-in trigger button, null renders none

SearchPanelResults

Props

PropTypeDefaultDescription
resultsSearchResult[][]Array of search results
loadingbooleanfalseShow loading state
defaultResultsSearchResultGroup[][]Groups of results shown while the query is empty, so users see what to type
emptyMessagestring"No results found"Message when no results
loadingMessagestring"Searching..."Text next to the spinner
onSelect(result: SearchResult) => void-Callback when result is selected

SearchPanelCommands / SearchPanelFederated

Props

PropTypeDefaultDescription
defaultResultsSearchResultGroup[][]Groups of results shown while the query is empty, so users see what to type
labels{ hint?, hintSuffix?, commands?, navigate?, open?, close?, noCommands? }-Footer and group texts of the palette (hint, hintSuffix, commands, navigate, open, close, noCommands)

SearchResult Type

interface SearchResult {
  id: string
  title: string
  description?: string
  category?: string
  icon?: React.ReactNode
  href?: string
  keywords?: string[]
  query?: string // puts the text into the input on select
}

interface SearchResultGroup {
  id?: string
  label: string
  icon?: React.ReactNode
  items: SearchResult[]
}

Features

  • 5 Search Patterns — instant, command palette, scoped, contextual, federated
  • Keyboard Navigation — ⌘K opens the command palette, Tab moves through results, Escape closes
  • Debounced Input — configurable delay for instant search
  • Multi-Source — search across multiple data sources simultaneously
  • Contextual — shows recent, trending, and personalized suggestions
  • Accessible — proper ARIA attributes and keyboard support