# KptMenu (kpt-menu) A dropdown menu on CDK Overlay. The trigger comes through projection, the entries through `items`. Requires `import '@angular/cdk/overlay-prebuilt.css';` Import: `import { KptMenu, KptMenuItem } from '@konce-pt/angular';` ## Inputs / outputs - `items`: readonly KptMenuItem[] - `open`: model (default false) - two-way; the panel's open state. Public so the application can own it: closing the menu after navigation, or opening it from a keyboard shortcut, cannot be expressed through `(selected)` alone. - `selected`: output - emitted only for regular entries (not for headers) ## KptMenuItem - `label?`, `value?`, `icon?`, `disabled?`, `danger?`, `separator?` - `description?: string` - a second line of text (an e-mail, a role, an action description) - `badge?: string | number` - a badge on the right side of the entry; `badgeVariant?: KptBadgeVariant` (default `primary`). Rendered through `kpt-badge`, so numbers above 99 collapse to `99+`. - `avatar?: { src?, name?, icon? }` - an avatar on the left (`kpt-avatar`, size `sm`); `name` without `src` produces initials. Used in the header row. - `header?: boolean` - a header row: a non-clickable block of text instead of a menu entry. It holds the signed-in user's details (`avatar` + `label` + `description`) or a description of what the menu does. Rendered as a `
` - it does not take focus and is not a `menuitem`. - `items?`, `url?` - used by the menubar / megamenu; an entry with `url` (no children, not disabled) renders as `` The `header`, `description`, `badge` and `avatar` fields are honored by `kpt-context-menu` and `kpt-split-button` too. ## Example items: KptMenuItem[] = [ { header: true, avatar: { src: '/u/anna.jpg' }, label: 'Anna Kowalska', description: 'anna@example.com' }, { separator: true }, { label: 'Profile', value: 'profile', icon: 'user' }, { label: 'Notifications', value: 'notif', icon: 'bell', badge: 4, badgeVariant: 'success' }, { separator: true }, { label: 'Sign out', value: 'logout', icon: 'logout', danger: true }, ]; ## Tokens The panel `--kpt-color-surface-raised`, `--kpt-elevation-3`; a danger entry `--kpt-color-danger`; descriptions and icons `--kpt-color-on-surface-muted`, `--kpt-font-size-xs`. ## Keyboard - `ArrowDown` / `ArrowUp` on the trigger open the menu with focus on the first / last item; a click, `Enter` or `Space` opens it on the first. - Inside: `ArrowDown` / `ArrowUp` move between items and wrap around, `Home` / `End` jump to the ends; disabled items, separators and headers are skipped. - `Escape` and `Tab` close the menu, and so does picking an item - focus returns to the trigger. - Items carry `tabindex="-1"` (roving focus), so an open menu is one Tab stop, not one per item. The logic lives in `menu-keys.ts`, shared with `kpt-split-button`; the other port has a twin file. ## A11y The panel is `role="menu"`, entries are `role="menuitem"` (native `