Component

Command

A command palette. Type to filter grouped items by label or keywords, run one with Enter or a shortcut, and open it inline or as a ⌘K dialog.

Inline palette

Photos
New photo ⌘N Search album ⌘F
Manage
ArchiveDelete (locked)
Enter to run

Selected: — · Query: —

import { ChangeDetectionStrategy, Component, signal } from '@angular/core';

import { HbCommandImports } from '@herbst/ui';

@Component({
  selector: 'hb-demo-command-inline',
  imports: [HbCommandImports],
  template: `
    <div class="flex w-full max-w-md flex-col gap-2">
      <hb-command
        class="block rounded-lg border border-border"
        (hbSelect)="last.set($event)"
        (hbCommandChange)="query.set($event)"
      >
        <hb-command-input hbPlaceholder="Search actions…" />
        <hb-command-list>
          <hb-command-empty>No results found.</hb-command-empty>

          <hb-command-group hbHeading="Photos">
            <hb-command-item [hbValue]="'new'" hbLabel="New photo" [hbKeywords]="['add', 'create']">
              New photo
              <span hb-command-shortcut>⌘N</span>
            </hb-command-item>
            <hb-command-item [hbValue]="'search'" hbLabel="Search album">
              Search album
              <span hb-command-shortcut>⌘F</span>
            </hb-command-item>
          </hb-command-group>

          <hb-command-separator />

          <hb-command-group hbHeading="Manage">
            <hb-command-item [hbValue]="'archive'" hbLabel="Archive">Archive</hb-command-item>
            <hb-command-item [hbValue]="'delete'" hbLabel="Delete" hbDisabled
              >Delete (locked)</hb-command-item
            >
          </hb-command-group>
        </hb-command-list>

        <div hb-command-footer class="px-3 py-2 text-[11px] text-muted-foreground">
          Enter to run
        </div>
      </hb-command>

      <p class="font-mono text-[12px] text-muted-foreground">
        Selected: {{ last() ?? '—' }} · Query: {{ query() || '—' }}
      </p>
    </div>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoCommandInlineComponent {
  protected readonly last = signal<unknown>(null);
  protected readonly query = signal('');
}

Dialog (⌘K)

Sizes

OakBeechOakBeech

API reference

hb-command

PropertyDescriptionTypeDefault
[hbSize] Height and text scale of the palette. 'xs' | 'sm' | 'md' | 'lg' | 'xl' 'md'
(hbSelect) Emits the value of the chosen item. unknown
(hbCommandChange) Emits the search query as it changes. string

hb-command-item

PropertyDescriptionTypeDefault
[hbValue] Value emitted when the item is chosen. unknown null
[hbLabel] Text the filter matches against. string ''
[hbKeywords] Extra search terms beyond the label. string[] []
[hbDisabled] Prevent the item from being selected. boolean false
(hbSelect) Emitted (with hbValue) when this item is chosen. unknown

Parts

PropertyDescriptionTypeDefault
hb-command-input [hbPlaceholder] The search field. slot
hb-command-list / hb-command-empty Scrollable results, and the message shown with no matches. slot
hb-command-group [hbHeading] A titled section of items. slot
hb-command-shortcut / hb-command-separator / hb-command-footer A key hint, a divider, and a footer bar. slot

hb-command-dialog

PropertyDescriptionTypeDefault
[(hbOpen)] Two-way open state of the palette dialog. boolean false
[hbHotkey] Key combined with ⌘/Ctrl to toggle the dialog (e.g. "k"). string ''