CommandPalette
Loading example…
Global search/command palette built on the in-house command primitive, shown in a modal dialog.
Import
Section titled “Import”import { CommandPalette } from "@jcsoftdev/ui/palette";Single-component entry points tree-shake to just this component: @jcsoftdev/ui/palette/command-palette.
<CommandPalette open items={items} label="Buscar en la barbería" placeholder="Buscar clientes, servicios o acciones..." emptyLabel="Sin resultados" closeKeyLabel="Esc"/>| Prop | Type | Default | Description |
|---|---|---|---|
open * |
boolean |
||
onClose * |
() => void |
||
items * |
CommandPaletteItem[] |
||
label * |
string |
Accessible name of the dialog. | |
placeholder * |
string |
||
emptyLabel * |
string |
Text shown when nothing matches. | |
formatResultCount * |
(count: number) => string |
Screen-reader announcement of the result count, e.g. (n) => \${n} results``. |
|
closeKeyLabel |
string |
"Esc" |
Hint for the close key shown next to the input. |
query |
string |
Controlled query, so the parent can react to typing (e.g. debounced remote search). | |
onQueryChange |
((query: string) => void) |
||
onSubmitQuery |
((query: string) => void) |
||
inputEnd |
ReactNode |
||
keepOpenOnSelect |
boolean |
false |
|
material |
"solid" | "glass" | "glass-clear" | "liquid" | "liquid-clear" |
Surface material. Omitted keeps the default for this layer; "glass" and "glass-clear" are frosted glass, "liquid" and "liquid-clear" Liquid Glass (with its fallbacks), "solid" forces an opaque surface. Liquid options go in style (liquidStyle() f… |
|
className |
string |
||
style |
CSSProperties |
Inline style of the root (for example liquidStyle() options). |
|
classNames |
Partial<Record<CommandPalettePart, string>> |
Per-part classes merged with cn; consumer classes win. className still targets the root and is merged last. |
* marks a required prop.
Storybook stories
Section titled “Storybook stories”- Default
- Empty
- Custom Close Key
- Controlled Query
- Type Select And Close
- Escape Closes
- Submit Query
- Input End
- Keep Open
Source
Section titled “Source”packages/ui/src/palette/command-palette/command-palette.tsx