- Docs
- Components
- Actions
Command palette
Search or jump to: anything in the console, by name, from the top bar or ⌘K.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.6
- Renders
<div role="dialog">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// Experimental: from the package's experimental entry, until it's stable.
import { CommandPalette } from "@qeetrix/react/experimental";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
groups | readonly CommandGroup[] | required | The results, grouped: { label, items }. |
onSelect | (item: CommandItem) => void | required | Called with the chosen item; the palette then closes. |
open | boolean | — | Open, controlled: wire it to the top bar's search. |
defaultOpen | boolean | false | Open to start with, uncontrolled. |
onOpenChange | (open: boolean) => void | — | Called as it opens or closes: ⌘K, Escape, a choice. |
hotkey | boolean | true | Opens and closes with ⌘K or Ctrl+K anywhere on the page. |
onQueryChange | (query: string) => void | — | Search yourself as the query changes; groups are then shown as given. |
loading | boolean | false | Shows "Searching…", for onQueryChange. |
placeholder | string | "Search or jump to…" | The search box's placeholder. |
messages | Partial<…commandPalette> | — | This palette's words, over QeetrixProvider's. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
command-palette | <div role="dialog"> | The popup, over a backdrop. |
command-list | <div role="listbox"> | The results, in their groups. |
command-item | <div role="option"> | A result. data-highlighted on the one Enter opens. |
command-item-leading | <span> | Its icon or avatar. |
command-item-meta | <span> | Where it lives, or its kind. |
04
A result's fields
CommandItem: what it's called, how it's found, and where it lives.
const groups: CommandGroup[] = [
{
label: "Settings",
items: [
{
value: "set_mfa",
label: "Two-step sign-in",
meta: "Security › Policies",
icon: ShieldCheckIcon,
keywords: ["MFA", "2FA", "OTP"],
},
],
},
{
label: "Actions",
items: [{ value: "invite", label: "Invite a user", icon: UserPlusIcon, shortcut: ["I"] }],
},
];