Skip to content

Command Palette for Angular

AngularNavigation

Keyboard-first command search in a modal dialog, opened with Ctrl+K (Cmd+K on Apple platforms; configurable) or a button: a search field over a grouped, virtualized listbox driven by aria-activedescendant. Fuzzy matching highlights matched characters; sections for recent commands, command groups, and async providers (debounced and aborted on each keystroke) with a loading state; nested pages for commands with children (Backspace goes back); an Empty State when nothing matches; shortcuts shown with Kbd. Commands are plain data with an optional run callback.

  • Ctrl+K anywhereA modal command search with a configurable shortcut, shown with Kbd, and focus restored on close.
  • Fuzzy and highlightedSubsequence matching over labels and keywords; matched characters are marked with text nodes.
  • Sections and pagesRecent commands, groups, and nested pages: Enter opens a sub-list, Backspace goes back.
  • Async providersServer searches are debounced and aborted on each keystroke, with a loading state.
  • Virtualized resultsThousands of commands stay fast; the listbox keeps focus in the field with aria-activedescendant.

Behavior, design tokens, and limitations are described on the Command Palette page; this page covers the Angular API.

import { Component } from '@angular/core';
import { AuiCommandPalette } from '@absoluteui/angular/command-palette';
import type { Command, CommandPaletteSelectDetail } from '@absoluteui/components/command-palette';
@Component({
selector: 'app-shell-search',
imports: [AuiCommandPalette],
template: `<aui-command-palette [commands]="commands" (selected)="onSelect($event)"></aui-command-palette>`,
})
export class ShellSearchComponent {
readonly commands: Command[] = [{ id: 'home', label: 'Go to dashboard', group: 'Navigation' }];
last = '';
onSelect(detail: CommandPaletteSelectDetail): void {
this.last = detail.id;
}
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiCommandPalette } from '@absoluteui/angular/command-palette';

Defaults for every instance: provideAbsoluteUIConfig({ components: { commandPalette: { ... } } }) (see Configuration).

Class AuiCommandPalette; template reference #ref="auiCommandPalette".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Input Type Default Description
commands readonly Command[] Required. Commands: { id, label, keywords?, group?, description?, shortcut?, icon?, children?, disabled?, run? }.
label string 'Command palette' Accessible name of the dialog.
placeholder string 'Type a command or search' Search field placeholder.
providers readonly CommandProvider[] Async searches ({ id, label, search(query, { signal }), minQueryLength? }), listed after the commands.
recent readonly string[] '[]' Command ids shown in the Recent section while the query is empty.
recentLimit number '5' Most recent commands remembered (0 hides the section).
maxResults number '50' Most results per section.
icons Partial<CommandPaletteIcons> Search, loading, back, and submenu icons.
shortcut string | null 'Mod+K' Hotkey that opens and closes the palette (matchesHotkey syntax; Mod is Cmd on Apple platforms, Ctrl elsewhere); null for none.
debounce number '200' Milliseconds between the last keystroke and provider searches (0 to 2000).
overscan number '6' Rows rendered beyond each edge of the visible area.
locale string 'en-US' Locale of messages and matching.
density Density 'comfortable' Row height.
Output Payload Description
(selected) CommandPaletteSelectDetail A command was chosen: { id, command, path, query, providerId }; preventDefault() skips command.run. The palette closes first. Re-emits aui-select.
(opened) null The palette opened. Re-emits aui-open.
(closed) null The palette closed. Re-emits aui-close.

Call them through a viewChild query or a template reference.

Method Description
open(options?: { page?: string; query?: string; } | undefined): void | undefined Open, optionally on a command’s nested page and with a query.
close(): void Close and restore focus.
toggle(): void Open or close.
setQuery(query: string): void Replace the search text and search.

Pattern: Modal dialog (native <dialog>, inert background) containing a WAI-ARIA 1.2 combobox whose listbox is always shown: focus stays in the search field and aria-activedescendant points at the active option. Section headers are presentational rows; the active option always stays rendered while the list is virtualized.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Command Palette: Accessibility and performance.