Skip to content

Command

<ax-command> is a searchable command list (palette body) driven by an items array with subsequence matching on label / keywords. Use it inline, or wrap it in <ax-command-dialog> for the modal ⌘K variant (a <ax-command> inside a dialog).

import {
AxCommandComponent,
AxCommandDialogComponent,
type CommandItem,
type CommandKeyBindings,
} from '@axisui-ng/navigation';
commands: CommandItem[] = [
{ id: 'new-file', label: 'New File', icon: 'file', group: '⌘N' },
{ id: 'settings', label: 'Open Settings', icon: 'settings', keywords: ['prefs'] },
{ id: 'download', label: 'Download', icon: 'download', disabled: true },
];
<!-- modal ⌘K palette -->
<ax-command-dialog [(open)]="open" [items]="commands" (select)="run($event)" />
<!-- inline palette -->
<ax-command
[items]="commands"
placeholder="Search…"
(select)="run($event)"
(close)="open = false"
/>

CommandItem is { id, label, group?, keywords?, icon?, disabled? }.

InputTypeDefaultNotes
itemsCommandItem[] (required)The searchable commands.
placeholderstring'Type a command…'Search field placeholder.
emptyTextstring'No results.'Shown when nothing matches.
keyBindingsPartial<CommandKeyBindings>{}Override any subset of keyboard bindings (KeyboardEvent.key strings).
pageSizenumber5How many enabled options PageUp/PageDown jump by.
OutputPayloadNotes
selectCommandItemEmitted when an item is chosen.
closevoidEmitted when the close binding (Escape by default) is pressed; does not stop propagation so a wrapping dialog can still close.
InputTypeDefaultNotes
openmodel<boolean>falseTwo-way open state.
itemsCommandItem[] (required)The searchable commands.
placeholderstring'Type a command…'Forwarded to the inner <ax-command>.
OutputPayloadNotes
selectCommandItemChosen command; the dialog then sets open to false.

Defaults (override via keyBindings):

ActionDefault key
Next / previousArrowDown / ArrowUp
Page down / upPageDown / PageUp
First / lastHome / End
SelectEnter
CloseEscape

Disabled options are skipped; navigation never wraps.

The search field is a combobox (aria-autocomplete="list", aria-controls, aria-activedescendant) over a listbox of options. A polite live region announces result counts. The dialog variant uses an sr-only title (“Command palette”) and traps focus while open via the underlying dialog.

Interactive examples live in Storybook under Navigation / Command. Run pnpm storybook to explore them.