CommandPalette
Cmd+K palette. Type to filter, arrows move one highlight that stretches between rows, Enter runs. Overlays.
Open playgroundAbout
CommandPalette is a React component in the Overlays category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CommandPalette } from "@ashutoshswamy/smoui" and set groups, trigger, open.
Install
npm i @ashutoshswamy/smouiUsage
import { CommandPalette } from "@ashutoshswamy/smoui";
<CommandPalette
trigger="Search"
groups={[{ heading: "Suggestions", items: [{ id: "new", label: "New document", hint: "N", onSelect: create }] }]}
/>Props 3
- groups
Commands, grouped.
{ heading: string; items: { id; label; icon?; hint?; keywords?; onSelect? }[] }[]- trigger / shortcut
Opening button and the Cmd/Ctrl+K shortcut.
ReactNode / booleandefault- / true- open / onOpenChange
Controlled state.
boolean / (open: boolean) => void
More overlays components
- ConfirmPopoverA small are-you-sure that opens beside its button instead of taking over the page. A failed action stays open and says so.
- ContextMenuRight-click, long-press or press the Menu key for a menu that opens out of the exact point you pressed. It flips to stay on screen and moves with the arrow keys.
- DialogA modal that grows out of its trigger, traps focus and keeps its header and footer in view while long content scrolls. Alert mode guards destructive decisions; the confirm button handles async work and failure itself.
- DropdownA menu with one highlight that stretches between rows. Arrow keys, Home and End move it, Enter picks, Escape closes.
- HoverCardA card that opens when you rest on a name, stays while you move onto it and closes when you leave.
- LightboxA grid of pictures. Click one and it grows out of its place into a viewer; swipe, use arrows or keys to move on.