"use client";
import { CommandPalette } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
options (required) | readonly PixxlAction[] | — | Options to choose from. |
defaultQuery | string | — | Initial search text (uncontrolled). |
onValueChange | (value: string) => void | — | Called with the id of the last command run when it changes. |
defaultValue | string | — | Initial value when uncontrolled. |
emptyLabel | ReactNode | — | Shown when no command matches the query. |
filter | (option: PixxlAction, query: string) => boolean | case-insensitive label substring | Custom matcher (default: case-insensitive label substring). |
inputLabel | string | — | — |
onAction | (id: string) => void | — | Called with the id of every command run (also when it is run again). |
onEscapeKeyDown | (event: KeyboardEvent) => void | — | — |
onQueryChange | (query: string) => void | — | — |
placeholder | string | — | — |
query | string | — | Search text (controlled). |
value | string | — | Current value (controlled); null where it means "nothing selected". |
optionsrequiredreadonly PixxlAction[]
Options to choose from.
defaultQuerystring
Initial search text (uncontrolled).
onValueChange(value: string) => void
Called with the id of the last command run when it changes.
defaultValuestring
Initial value when uncontrolled.
emptyLabelReactNode
Shown when no command matches the query.
filterdefault case-insensitive label substring(option: PixxlAction, query: string) => boolean
Custom matcher (default: case-insensitive label substring).
inputLabelstring
onAction(id: string) => void
Called with the id of every command run (also when it is run again).
onEscapeKeyDown(event: KeyboardEvent) => void
onQueryChange(query: string) => void
placeholderstring
querystring
Search text (controlled).
valuestring
Current value (controlled); null where it means "nothing selected".
Other props are passed to the root element (HTMLAttributes<HTMLDivElement>), including className, style, id and aria-* attributes.
const actions = [
{ id: "copy", label: "Copy" },
{ id: "rename", label: "Rename" },
];
const run = (id: string | null) => console.log(id);
<CommandPalette options={actions} defaultQuery="co" onValueChange={run} />