Component
CommandSearch
Build a modal command palette with grouped results, filtering, keyboard navigation, and optional shortcut.
Interactive preview
Usage
Import the component entry and start with its smallest complete example.
Import
import { CommandSearch } from "@chitrank2050/monoline-ui/command-search"Basic usage
<CommandSearch
open={open}
onOpenChange={setOpen}
placeholder="Search docs or actions..."
showFooter
>
<CommandSearch.Input />
<CommandSearch.List>
<CommandSearch.Group heading="Documentation">
<CommandSearch.Item value="navbar component" onSelect={() => navigate("/navbar")}>
Navbar Component
</CommandSearch.Item>
<CommandSearch.Item value="select component" onSelect={() => navigate("/select")}>
Select Component
</CommandSearch.Item>
</CommandSearch.Group>
<CommandSearch.Empty />
</CommandSearch.List>
</CommandSearch>Usage guidance
Choose the component for its interaction model and semantics before customizing its appearance.
CommandSearch suits a controlled, keyboard-driven search or command palette with filterable actions.
Search should stay visible on the page or results exist only on the server with no client controller.
CommandSearch delegates command-list semantics to cmdk and closes on Escape, while the caller must provide an accessible opener and restore focus when the portal closes.
This component needs browser JavaScript for state or browser APIs.
API reference
Props, slots, and callbacks available on this component.
Design tokens
Theme variables this component reads for color, spacing, and motion.
Implementation
The source used by the example above, including any state it needs.
import { useState } from "react"
import { Button } from "@chitrank2050/monoline-ui/button"
import { CommandSearch } from "@chitrank2050/monoline-ui/command-search"
export function SearchTrigger() {
const [open, setOpen] = useState(false)
return (
<>
<Button onClick={() => setOpen(true)}>Open Palette</Button>
<CommandSearch
open={open}
onOpenChange={setOpen}
placeholder="Type to search..."
shortcut={false} // Disable global shortcut to prevent page conflicts
>
<CommandSearch.Input />
<CommandSearch.List>
<CommandSearch.Group heading="Links">
<CommandSearch.Item value="home" onSelect={() => navigate("/home")}>
Home
</CommandSearch.Item>
<CommandSearch.Item value="about" onSelect={() => navigate("/about")}>
About
</CommandSearch.Item>
</CommandSearch.Group>
<CommandSearch.Empty />
</CommandSearch.List>
{/* Render the default footer layout */}
<CommandSearch.Footer />
</CommandSearch>
</>
)
}Related documentation
Compare related components or review the package and theme setup.