Usage#
app.component.tsimport { WDS_COMMAND } from '@wds/angular/command';Examples#
Default#
Groups, icons, shortcuts and a disabled command. Selecting a command (click or Enter) fires wds-select with its value and label. Set label, placeholder and empty-text: their defaults are in Polish.
Calendar
Search Emoji
Calculator
Profile
Billing
Settings
Show code
command-default.tsimport { Component } from '@angular/core';
import { WdsCommandComponent, WdsCommandGroupComponent, WdsCommandItemComponent, WdsCommandSeparatorComponent } from '@wds/angular/command';
import '@wds/core/icons/lucide/calendar';
import '@wds/core/icons/lucide/smile';
import '@wds/core/icons/lucide/calculator';
import '@wds/core/icons/lucide/user';
import '@wds/core/icons/lucide/credit-card';
import '@wds/core/icons/lucide/settings';
@Component({
selector: 'app-command-default-demo',
imports: [WdsCommandComponent, WdsCommandGroupComponent, WdsCommandItemComponent, WdsCommandSeparatorComponent],
template: `
<wds-command class="w-full max-w-sm" label="Search commands" placeholder="Type a command or search…" empty-text="No results found.">
<wds-command-group label="Suggestions">
<wds-command-item value="calendar" icon-start="lucide-calendar">
Calendar
</wds-command-item>
<wds-command-item value="emoji" icon-start="lucide-smile">
Search Emoji
</wds-command-item>
<wds-command-item value="calculator" disabled icon-start="lucide-calculator">
Calculator
</wds-command-item>
</wds-command-group>
<wds-command-separator></wds-command-separator>
<wds-command-group label="Settings">
<wds-command-item value="profile" shortcut="⌘P" icon-start="lucide-user">
Profile
</wds-command-item>
<wds-command-item value="billing" shortcut="⌘B" icon-start="lucide-credit-card">
Billing
</wds-command-item>
<wds-command-item value="settings" shortcut="⌘S" icon-start="lucide-settings">
Settings
</wds-command-item>
</wds-command-group>
</wds-command>
`,
})
export class CommandDefaultDemo {} Dialog#
The palette in a wds-dialog, opened with a button or ⌘J / Ctrl+J. The dialog has a heading for screen readers, hidden visually. The shortcut is handled by the page.
Open command palette Or press ⌘J · Selected: none
CalendarSearch EmojiCalculatorProfileBillingSettings Show code
command-dialog.tsimport { Component, ElementRef, signal, viewChild } from '@angular/core';
import { WdsButtonComponent } from '@wds/angular/button';
import { WDS_COMMAND } from '@wds/angular/command';
import { WdsDialogComponent } from '@wds/angular/dialog';
import { WDS_KBD } from '@wds/angular/kbd';
import type { WdsCommand } from '@wds/core/command';
import type { WdsDialog } from '@wds/core/dialog';
@Component({
selector: 'app-command-dialog-demo',
imports: [...WDS_COMMAND, ...WDS_KBD, WdsButtonComponent, WdsDialogComponent],
host: { '(document:keydown)': 'onKeydown($event)' },
template: `
<div class="flex flex-col items-center gap-3">
<wds-button variant="outline" (click)="open()">Open command palette</wds-button>
<p class="m-0 text-sm text-muted-foreground">
Or press
<wds-kbd-group><wds-kbd>⌘</wds-kbd><wds-kbd>J</wds-kbd></wds-kbd-group>
· Selected: {{ selected() || 'none' }}
</p>
</div>
<wds-dialog
#dialog
heading="Command palette"
hide-close
class="[--wds-dialog-width:24rem] [&::part(body)]:p-0 [&::part(header)]:sr-only [&::part(panel)]:border-0 [&::part(panel)]:bg-transparent [&::part(panel)]:shadow-none"
(wdsAfterClose)="resetSearch()"
>
<wds-command
#command
label="Search commands"
placeholder="Type a command or search…"
empty-text="No results found."
(wdsSelect)="choose($event.label)"
>
<wds-command-group label="Suggestions">
<wds-command-item value="calendar">Calendar</wds-command-item>
<wds-command-item value="emoji">Search Emoji</wds-command-item>
<wds-command-item value="calculator">Calculator</wds-command-item>
</wds-command-group>
<wds-command-separator />
<wds-command-group label="Settings">
<wds-command-item value="profile" shortcut="⌘P">Profile</wds-command-item>
<wds-command-item value="billing" shortcut="⌘B">Billing</wds-command-item>
<wds-command-item value="settings" shortcut="⌘S">Settings</wds-command-item>
</wds-command-group>
</wds-command>
</wds-dialog>
`,
})
export class CommandDialogDemo {
protected readonly selected = signal('');
private readonly dialog = viewChild.required('dialog', { read: ElementRef<WdsDialog> });
private readonly command = viewChild.required('command', { read: ElementRef<WdsCommand> });
protected onKeydown(e: KeyboardEvent): void {
if (e.key.toLowerCase() !== 'j' || !(e.metaKey || e.ctrlKey)) return;
e.preventDefault();
this.open();
}
protected open(): void {
this.dialog().nativeElement.show();
this.command().nativeElement.focus();
}
protected choose(label: string): void {
this.selected.set(label);
this.dialog().nativeElement.close();
}
/** Start with an empty search next time. */
protected resetSearch(): void {
this.command().nativeElement.query = '';
}
} A long list scrolls inside the palette; --wds-command-list-height sets its maximum height (default 288px).
Home
Inbox
Documents
Folders
New File
New Folder
Copy
Cut
Paste
Delete
Grid View
List View
Zoom In
Zoom Out
Profile
Billing
Settings
Notifications
Help & Support
Calculator
Calendar
Image Editor
Code Editor
Show code
command-scrollable.tsimport { Component } from '@angular/core';
import { WdsCommandComponent, WdsCommandGroupComponent, WdsCommandItemComponent, WdsCommandSeparatorComponent } from '@wds/angular/command';
import '@wds/core/icons/lucide/house';
import '@wds/core/icons/lucide/inbox';
import '@wds/core/icons/lucide/file-text';
import '@wds/core/icons/lucide/folder';
import '@wds/core/icons/lucide/plus';
import '@wds/core/icons/lucide/folder-plus';
import '@wds/core/icons/lucide/copy';
import '@wds/core/icons/lucide/scissors';
import '@wds/core/icons/lucide/clipboard-paste';
import '@wds/core/icons/lucide/trash';
import '@wds/core/icons/lucide/layout-grid';
import '@wds/core/icons/lucide/list';
import '@wds/core/icons/lucide/zoom-in';
import '@wds/core/icons/lucide/zoom-out';
import '@wds/core/icons/lucide/user';
import '@wds/core/icons/lucide/credit-card';
import '@wds/core/icons/lucide/settings';
import '@wds/core/icons/lucide/bell';
import '@wds/core/icons/lucide/circle-question-mark';
import '@wds/core/icons/lucide/calculator';
import '@wds/core/icons/lucide/calendar';
import '@wds/core/icons/lucide/image';
import '@wds/core/icons/lucide/code';
@Component({
selector: 'app-command-scrollable-demo',
imports: [WdsCommandComponent, WdsCommandGroupComponent, WdsCommandItemComponent, WdsCommandSeparatorComponent],
template: `
<wds-command class="w-full max-w-sm" label="Search commands" placeholder="Type a command or search…" empty-text="No results found.">
<wds-command-group label="Navigation">
<wds-command-item value="home" shortcut="⌘H" icon-start="lucide-house">
Home
</wds-command-item>
<wds-command-item value="inbox" shortcut="⌘I" icon-start="lucide-inbox">
Inbox
</wds-command-item>
<wds-command-item value="documents" shortcut="⌘D" icon-start="lucide-file-text">
Documents
</wds-command-item>
<wds-command-item value="folders" shortcut="⌘F" icon-start="lucide-folder">
Folders
</wds-command-item>
</wds-command-group>
<wds-command-separator></wds-command-separator>
<wds-command-group label="Actions">
<wds-command-item value="new-file" shortcut="⌘N" icon-start="lucide-plus">
New File
</wds-command-item>
<wds-command-item value="new-folder" shortcut="⇧⌘N" icon-start="lucide-folder-plus">
New Folder
</wds-command-item>
<wds-command-item value="copy" shortcut="⌘C" icon-start="lucide-copy">
Copy
</wds-command-item>
<wds-command-item value="cut" shortcut="⌘X" icon-start="lucide-scissors">
Cut
</wds-command-item>
<wds-command-item value="paste" shortcut="⌘V" icon-start="lucide-clipboard-paste">
Paste
</wds-command-item>
<wds-command-item value="delete" shortcut="⌫" variant="destructive" icon-start="lucide-trash">
Delete
</wds-command-item>
</wds-command-group>
<wds-command-separator></wds-command-separator>
<wds-command-group label="View">
<wds-command-item value="grid" icon-start="lucide-layout-grid">
Grid View
</wds-command-item>
<wds-command-item value="list" icon-start="lucide-list">
List View
</wds-command-item>
<wds-command-item value="zoom-in" shortcut="⌘+" icon-start="lucide-zoom-in">
Zoom In
</wds-command-item>
<wds-command-item value="zoom-out" shortcut="⌘-" icon-start="lucide-zoom-out">
Zoom Out
</wds-command-item>
</wds-command-group>
<wds-command-separator></wds-command-separator>
<wds-command-group label="Account">
<wds-command-item value="profile" shortcut="⌘P" icon-start="lucide-user">
Profile
</wds-command-item>
<wds-command-item value="billing" shortcut="⌘B" icon-start="lucide-credit-card">
Billing
</wds-command-item>
<wds-command-item value="settings" shortcut="⌘S" icon-start="lucide-settings">
Settings
</wds-command-item>
<wds-command-item value="notifications" icon-start="lucide-bell">
Notifications
</wds-command-item>
<wds-command-item value="help" icon-start="lucide-circle-question-mark">
Help & Support
</wds-command-item>
</wds-command-group>
<wds-command-separator></wds-command-separator>
<wds-command-group label="Tools">
<wds-command-item value="calculator" icon-start="lucide-calculator">
Calculator
</wds-command-item>
<wds-command-item value="calendar" icon-start="lucide-calendar">
Calendar
</wds-command-item>
<wds-command-item value="image" icon-start="lucide-image">
Image Editor
</wds-command-item>
<wds-command-item value="code" icon-start="lucide-code">
Code Editor
</wds-command-item>
</wds-command-group>
</wds-command>
`,
})
export class CommandScrollableDemo {} Keywords#
The search ignores case and diacritics, so “lodz” finds “Łódź”. keywords adds words that match without being shown. The empty slot replaces the message shown when nothing matches.
Settings
Billing
Log out
Łódź
Zürich
São Paulo
Nothing found. Try another word.
Show code
command-keywords.tsimport { Component } from '@angular/core';
import { WdsCommandComponent, WdsCommandGroupComponent, WdsCommandItemComponent } from '@wds/angular/command';
@Component({
selector: 'app-command-keywords-demo',
imports: [WdsCommandComponent, WdsCommandGroupComponent, WdsCommandItemComponent],
template: `
<wds-command class="w-full max-w-sm" label="Search commands" placeholder="Try “preferences” or “sign out”…">
<wds-command-group label="Account">
<wds-command-item value="settings" keywords="preferences options">Settings</wds-command-item>
<wds-command-item value="billing" keywords="payment invoice card">Billing</wds-command-item>
<wds-command-item value="logout" keywords="sign out exit">Log out</wds-command-item>
</wds-command-group>
<wds-command-group label="Places">
<wds-command-item value="lodz">Łódź</wds-command-item>
<wds-command-item value="zurich">Zürich</wds-command-item>
<wds-command-item value="sao-paulo">São Paulo</wds-command-item>
</wds-command-group>
<div slot="empty">Nothing found. Try another word.</div>
</wds-command>
`,
})
export class CommandKeywordsDemo {} API References#
wds-command#
Command palette: a search field and a filtered list of commands.
Focus stays in the search field; the arrow keys move the highlight (skipping disabled commands),
Enter selects, Escape goes back to the first command. aria-activedescendant points to the
highlighted command, and an aria-live region announces the number of results.
Attributes
| Attribute | Type | Default | Description |
|---|
| placeholder | string | '' | Placeholder of the search field. Empty: built-in text (command.placeholder). |
| empty-text.emptyText | string | '' | Message shown when nothing matches. The empty slot takes precedence. Empty: built-in text (common.noResults). |
| label | string | '' | Accessible name of the search field and the list. Empty: built-in text (command.label). |
| query | string | '' | Search text. Setting it filters the list without firing wds-search. |
Events
| Event | Description |
|---|
| wds-selectCustomEvent<WdsCommandSelectDetail> | A command is selected (click or Enter). |
| wds-searchCustomEvent<WdsCommandSearchDetail> | The search text changes. |
Methods
| Method | Description |
|---|
| moveActive(step: 1 | -1) | Moves the highlight to the next (1) or previous (-1) visible command. For a list driven from outside
the search field, e.g. a menu under the caret in a text editor that sets query itself. |
| selectActive() | Selects the highlighted command (fires wds-select). Returns false when nothing is highlighted. |
Slots
| Slot | Description |
|---|
| (default) | wds-command-group, wds-command-item, wds-command-separator. |
| empty | Content shown when nothing matches (instead of empty-text). |
CSS parts (::part)
| Part | Description |
|---|
| base | The panel with the padding and the border. |
| search | The search field (with the icon). |
| input | The native <input>. |
| list | The list of commands. |
| empty | The "no results" message. |
CSS custom properties
| Property | Description |
|---|
| --wds-command-border-color | Border color of the panel (default --wds-border). |
| --wds-command-list-height | Maximum height of the list (default 288px). |
wds-command-group#
A group of commands with a heading (role="group"). It hides when none of its commands match the search.
Attributes
| Attribute | Type | Default | Description |
|---|
| label | string | '' | Group heading (also the accessible name of the group). |
Slots
| Slot | Description |
|---|
| (default) | wds-command-item. |
CSS parts (::part)
| Part | Description |
|---|
| label | The group heading. |
wds-command-item#
A command in the wds-command list (role="option"). The highlighted one has data-active.
Attributes
| Attribute | Type | Default | Description |
|---|
| value | string | '' | Value passed in wds-select. |
| label | string | undefined | | Name used for search and in wds-select. Defaults to the text content. |
| keywords | string | '' | Extra words matched by the search (e.g. synonyms, abbreviations). |
| shortcut | string | '' | Keyboard shortcut shown on the right, e.g. ⌘P. It is only displayed; handle the keys yourself. |
| variant | WdsCommandItemVariant | 'default' | destructive: the error color (e.g. "Delete"). |
| disabled | boolean | false | Disables the command: it cannot be highlighted or selected. |
| icon-start.iconStart | string | undefined | | Icon before the content: the name of a registered icon, e.g. lucide-calendar (after import '@wds/core/icons/lucide/calendar'). |
| icon-end.iconEnd | string | undefined | | Icon after the content: the name of a registered icon. |
Slots
| Slot | Description |
|---|
| (default) | The name of the command, optionally with your own <svg> or <wds-icon> instead of icon-start. |
CSS parts (::part)
| Part | Description |
|---|
| icon-start | The icon before the name (icon-start). |
| icon-end | The icon after the name (icon-end). |
| base | The row with the padding. |
| shortcut | The keyboard shortcut. |
wds-command-separator#
A decorative line between groups of commands, hidden from screen readers. Hidden while searching.
CSS parts (::part)
| Part | Description |
|---|
| base | The line. |
Accessibility#
Screen reader#
The search field has role="combobox" with aria-controls pointing to the list (role="listbox"). Both are named by label; its default is in Polish (Szukaj poleceń), so set it.
Focus stays in the search field. aria-activedescendant points to the highlighted command (role="option", aria-selected="true"); disabled commands have aria-disabled="true".
Groups have role="group" named by their label. Separators are decorative: hidden from screen readers, and hidden while searching. Shortcuts are hidden from screen readers too; give icons aria-hidden="true".
A live region announces the number of results after each change of the search, and a hidden hint on the search field describes the keys. Both texts are built in and currently in Polish.
In a wds-dialog, give the dialog a heading (it can be hidden visually) so the dialog has a name.
Keyboard support#
| Key | Function |
|---|
| A–Z | Typing filters the list; the first matching command is highlighted. |
| ArrowDownArrowUp | Moves the highlight to the next or previous command, wrapping around; disabled commands are skipped. |
| Enter | Selects the highlighted command. |
| Escape | Moves the highlight back to the first command. In a dialog, it also closes the dialog. |
| Tab | Leaves the palette: the commands are not in the tab sequence. |