Componente

Command

Uma paleta de comandos. Digite para filtrar itens agrupados por rótulo ou palavras-chave, execute um com Enter ou um atalho, e abra inline ou como um diálogo ⌘K.

Paleta inline

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('');
}

Diálogo (⌘K)

Tamanhos

OakBeechOakBeech

Referência de API

hb-command

PropriedadeDescriçãoTipoPadrão
[hbSize] Altura e escala de texto da paleta. 'xs' | 'sm' | 'md' | 'lg' | 'xl' 'md'
(hbSelect) Emite o valor do item escolhido. unknown
(hbCommandChange) Emite a busca conforme ela muda. string

hb-command-item

PropriedadeDescriçãoTipoPadrão
[hbValue] Valor emitido quando o item é escolhido. unknown null
[hbLabel] Texto contra o qual o filtro compara. string ''
[hbKeywords] Termos de busca extras além do rótulo. string[] []
[hbDisabled] Impede o item de ser selecionado. boolean false
(hbSelect) Emitido (com hbValue) quando este item é escolhido. unknown

Parts

PropriedadeDescriçãoTipoPadrão
hb-command-input [hbPlaceholder] O campo de busca. slot
hb-command-list / hb-command-empty Resultados roláveis, e a mensagem exibida sem correspondências. slot
hb-command-group [hbHeading] Uma seção de itens com título. slot
hb-command-shortcut / hb-command-separator / hb-command-footer Uma dica de tecla, um divisor e uma barra de rodapé. slot

hb-command-dialog

PropriedadeDescriçãoTipoPadrão
[(hbOpen)] Estado de abertura bidirecional do diálogo da paleta. boolean false
[hbHotkey] Tecla combinada com ⌘/Ctrl para alternar o diálogo (ex. "k"). string ''