Skip to main content
cngx-src documentation

CngxCommandPalette

cngx-command-palette

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/ui/command-palette/palette/command-palette.component.ts

Import#

import { CngxCommandPalette } from '@cngx/ui/command-palette'

Description#

The opinionated Cmd/Ctrl+K command palette preset. Renders the panel body + async-state shell inside a native modal <dialog cngxDialog>, so focus trapping, trigger storage at open, and focus restore after the close transition are handled by CngxDialog and the platform - no hand-rolled focus machinery. The palette provides CNGX_COMMAND_PALETTE_HOST so the panel can dismiss it when a command runs.

Type-to-filter runs over the merged command registry (injectCommands) plus the consumer's async [results]; the palette commits no form value - it fires command.run(), the locked demarcation from CngxCombobox. The global Cmd/Ctrl+K open combo is wired by the keybinding factory, not here.

<cngx-command-palette #palette [results]="results()" />
<button [cngxCommandPaletteTrigger]="palette">Search commands</button>

Metadata#

Providers#

CNGX_COMMAND_PALETTE_HOST
useExisting CngxCommandPalette

Relationships

Index#

Inputs#

ariaLabel#string
input()

Accessible name for the dialog.

default 'Command palette'
debounceMs#number
input()

Debounce for the search input.

default 150
openShortcut#string | undefined
input()

Per-instance open combo (parsed via parseKeyCombo, e.g. 'mod+shift+p'). Wins over CNGX_COMMAND_PALETTE_CONFIG.openShortcut (withPaletteShortcut), which wins over the 'mod+k' default. Changing it live re-installs the listener. For a full listener swap, override CNGX_PALETTE_KEYBINDING_FACTORY.

Consumer-derived async result source.

scope#string | undefined
model()

Two-way scope; feeds the matcher's scope filter and the panel chip.

Outputs#

retry#void
output()

Fired when the user asks to retry a failed result load.

scope#string | undefined
model()

Two-way scope; feeds the matcher's scope filter and the panel chip.

Instance Properties#

config#unknown
ProtectedReadonly
injectCommandPaletteConfig()

Methods#

dismiss#void

Dismiss the palette. Focus returns to the trigger via CngxDialog.

open#void

Open the palette.