Component

Menu

A dropdown and context menu built on the CDK menu. Trigger it by click, hover, or right-click; fill it with items, checkboxes, radio groups, labels, separators, shortcuts, and nested submenus.

Items, shortcuts & destructive

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

import { HbButtonComponent, HbMenuImports } from '@herbst/ui';

@Component({
  selector: 'hb-demo-menu-basic',
  imports: [HbMenuImports, HbButtonComponent],
  template: `
    <div class="flex flex-col items-start gap-2">
      <button hb-button [hbMenuTriggerFor]="menu" (hbOpenChange)="open.set($event)">
        {{ open() ? 'Open ▲' : 'Actions ▼' }}
      </button>
      <span class="font-mono text-[12px] text-muted-foreground">Last: {{ last() }}</span>
    </div>

    <ng-template #menu>
      <hb-menu>
        <hb-menu-label>Photo</hb-menu-label>
        <hb-menu-item (hbSelect)="last.set('Edit')">
          Edit
          <hb-menu-shortcut>⌘E</hb-menu-shortcut>
        </hb-menu-item>
        <hb-menu-item (hbSelect)="last.set('Duplicate')">
          Duplicate
          <hb-menu-shortcut>⌘D</hb-menu-shortcut>
        </hb-menu-item>
        <hb-menu-item hbDisabled>Archive (disabled)</hb-menu-item>
        <hb-menu-separator />
        <hb-menu-item hbVariant="destructive" (hbSelect)="last.set('Delete')">
          Delete
          <hb-menu-shortcut></hb-menu-shortcut>
        </hb-menu-item>
      </hb-menu>
    </ng-template>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoMenuBasicComponent {
  protected readonly open = signal(false);
  protected readonly last = signal('—');
}

Checkbox, radio & submenu

notes: true · sort: name

Hover & context menu

Right-click this area

API reference

Triggers

PropertyDescriptionTypeDefault
[hbMenuTriggerFor] Attach to any element, pointing at an ng-template that wraps an hb-menu. TemplateRef
[hbTrigger] / [hbDisabled] Open on click or hover, and optionally block opening. 'click' | 'hover' / boolean 'click' / false
[hbOpen] / (hbOpenChange) / [hbMenuPosition] Controlled open state, an open/close event, and custom CDK connected positions. boolean / boolean / ConnectedPosition[] undefined / — / —
[hbContextMenuTriggerFor] Open the menu at the pointer on right-click. [hbGlobal] captures right-clicks anywhere; [hbContextDisabled] disables it. TemplateRef

Items

PropertyDescriptionTypeDefault
hb-menu-item [hbVariant] [hbInset] A command row. default | destructive; hbInset aligns text with items that have indicators. Emits (hbSelect); [hbDisabled] disables it; add [hbMenuTriggerFor] to make a submenu. 'default' | 'destructive' 'default'
hb-menu-checkbox-item [(hbChecked)] A toggleable item with a check indicator. boolean false
hb-menu-radio-group [(hbValue)] + hb-menu-radio-item [hbValue] A single-choice group; the item whose value matches the group is marked selected. unknown null

Structure

PropertyDescriptionTypeDefault
hb-menu-label [hbInset] A non-interactive caption for a section. component
hb-menu-separator / hb-menu-group A dividing line, and a wrapper to group related items. component
hb-menu-shortcut Right-aligned muted text for a keyboard hint. component