Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 03 Actions

Command palette

A search over the app's actions, in a dialog. Ctrl+K or ⌘K opens it from anywhere; typing filters, the arrow keys move and Enter runs. Screen readers hear how many commands match as you type. Keep a visible button for it too: a shortcut nobody knows about is no way in.

Use it in Angular
import { CommandPaletteComponent, type Command } from '@okaapi-ui/angular';
// Built on the kit's dialog. Add @angular/cdk/overlay-prebuilt.css.

Commands

Press Ctrl+K (⌘K on a Mac) on this page, or the button. Try typing invoice: keywords find New order.

Angular
<button ui-button variant="secondary" (click)="open.set(true)">Commands</button>
<ui-command-palette [commands]="commands" [(open)]="open" (run)="go($event)" />

commands: Command[] = [
  { id: 'new', label: 'New order', keywords: ['invoice', 'bill'], shortcut: 'Ctrl N' },
  { id: 'find', label: 'Find a customer', keywords: ['search', 'client'] },
  { id: 'out', label: 'Sign out' },
];

When to use something else

If you needUse
Pick a value inside a formCombobox
Search the items of one listSearch field
A few actions on one thingMenu

Inputs

NameTypeDefaultWhat it does
commandsCommand[] — Required. { id, label, keywords?, shortcut? }. Keywords find a command by other words; shortcut is only shown.
shortcutstring | null'k'The letter that opens it with Ctrl or ⌘. null turns it off.
title | placeholderstring'Commands' from labelsNames the dialog and the field; text in the empty field.
emptyLabel | closeLabelstring — Shown when nothing matches; the close button. Translate them.
countLabel(count: number) => string`${n} commands` from labelsAnnounced as you type. Translate it.
[(open)]booleanfalseOpen or closed; Ctrl+K and Escape change it.
(run)Command — The command to run, after the dialog has closed and focus is back.

Keyboard and screen readers

KeysWhat they do
Ctrl + K or ⌘ + K Open it from anywhere.
Up or Down Move through the matching commands, wrapping round.
Enter Run the highlighted command.
Escape Close it.
  • How many commands match is announced as you type.
  • Keep a visible button for it too: a shortcut nobody knows about is no way in.