Components Advanced
CommandPalette
StableA global ⌘K / Ctrl+K command menu in a dialog for fast navigation and actions.
CommandPalette puts a CommandMenu in a modal dialog that opens from anywhere with a keyboard shortcut. Use it to give power users one place to jump between pages and run common actions. Mount one per app. The examples on this page use hotkey={false} (except the last) so they do not clash with the docs search on ⌘K.
Overview
import { Button, CommandGroup, CommandItem, CommandPalette, Icon } from '@bindshq/stance-react';
export function Basic() {
return (
<CommandPalette
hotkey={false}
trigger={
<Button variant="outline" leadingIcon={<Icon name="search" />}>
Search…
</Button>
}
>
<CommandGroup heading="Pages">
<CommandItem value="Dashboard" icon={<Icon name="home" />} />
<CommandItem value="My templates" icon={<Icon name="file-text" />} />
<CommandItem value="Org users" icon={<Icon name="users" />} />
<CommandItem value="Integrations" icon={<Icon name="link" />} />
</CommandGroup>
</CommandPalette>
);
}Light, dark and high contrast
Every Stance component is designed and tested in all three appearance modes.
Import
import { CommandPalette, CommandGroup, CommandItem } from '@bindshq/stance-react';Examples
import { Button, CommandGroup, CommandItem, CommandPalette, Icon, toast } from '@bindshq/stance-react';
export function WithActions() {
return (
<CommandPalette
hotkey={false}
placeholder="Jump to a page or run an action…"
trigger={<Button leadingIcon={<Icon name="command" />}>Open palette</Button>}
>
<CommandGroup heading="Actions">
<CommandItem
value="New template"
keywords={['create']}
icon={<Icon name="plus" />}
onSelect={() => toast('Creating a new template…')}
/>
<CommandItem
value="Deploy signatures"
keywords={['publish', 'push']}
icon={<Icon name="send" />}
onSelect={() => toast.success('Deployment started')}
/>
<CommandItem
value="Toggle theme"
keywords={['dark', 'light']}
icon={<Icon name="contrast" />}
/>
</CommandGroup>
<CommandGroup heading="Settings">
<CommandItem value="Billing" icon={<Icon name="credit-card" />} />
<CommandItem value="Security" icon={<Icon name="shield" />} />
</CommandGroup>
</CommandPalette>
);
}Custom hotkey
Press ⌘⇧P / Ctrl+Shift+P on this page.
import * as React from 'react';
import { Button, CommandGroup, CommandItem, CommandPalette, Icon } from '@bindshq/stance-react';
export function GlobalHotkey() {
const [open, setOpen] = React.useState(false);
return (
<div style={{ display: 'grid', gap: 8, justifyItems: 'center' }}>
<Button variant="secondary" onClick={() => setOpen(true)}>
Open (or press ⌘⇧P / Ctrl+Shift+P)
</Button>
<CommandPalette
open={open}
onOpenChange={setOpen}
hotkey="mod+shift+p"
label="Workspace switcher"
>
<CommandGroup heading="Workspaces">
<CommandItem value="Binds Ltd" icon={<Icon name="building" />} />
<CommandItem value="eSignify Demo" icon={<Icon name="building" />} />
</CommandGroup>
</CommandPalette>
</div>
);
}API reference
| Prop | Type | Default | Description |
|---|---|---|---|
hotkey | string | false | 'mod+k' | Global toggle shortcut; mod is ⌘ on Apple platforms and Ctrl elsewhere. |
open / defaultOpen / onOpenChange | boolean / boolean / (open: boolean) => void | None | Controlled or uncontrolled state. |
trigger | ReactElement | None | Optional button that opens the palette. |
label | string | 'Command palette' | Dialog title (visually hidden) and input label. |
placeholder | string | None | Input placeholder. |
emptyMessage | ReactNode | 'No results found.' | Shown when nothing matches. |
closeOnSelect | boolean | true | Close after an item runs. |
filter | CommandFilter | false | None | Custom scorer or disable filtering. |
showFooter | boolean | true | Keyboard hints footer (hidden on phones). |
children | ReactNode | None | CommandGroup and CommandItem elements. |
Accessibility
- A modal dialog with a visually hidden title; focus starts in the search combobox and returns to where it was on close.
- All CommandMenu keyboard behaviour applies inside.
- The shortcut is discoverable through the trigger button and the footer hint; never make the hotkey the only way in.
Keyboard
| Keys | Action |
|---|---|
| ⌘ K | Toggle the palette (Ctrl+K on Windows and Linux). |
| ↓ ↑ | Move through results. |
| Enter | Run the highlighted command and close. |
| Esc | Close. |
Usage guidelines
Do
- Show the shortcut on a visible trigger, e.g. “Search ⌘K”.
- Group results by type: pages, actions, people.
Don’t
- Register several palettes on one page with the same hotkey.