Menu
BasicOverlays
<co-menu>Menu lists actions in a dropdown; KebabMenu opens one from a three-dot button and Popover holds a small form or filter set.
import { Menu } from 'health-components';
Examples
Showcase
With Shortcuts
Kebab
Popover Filters
Usage
<KebabMenu label={"Actions for " + claim.id} items={[{ label: "Open Claim" }, { divider: true }, { label: "Void Claim", danger: true }]} />
<Popover trigger="Filters (2)" title="Filter claims">...</Popover>
When to use
- Row actions in tables, overflow actions in headers, filter popovers.
When not to use
- Navigation between screens: SidebarNav or Tabs.
Variants and states
| Variant | What it is |
|---|---|
| Menu | Items with icon, hint, shortcut; heading, divider, danger item, disabled item, active item. |
| KebabMenu | Vertical or horizontal dots. |
| Popover | Titled panel with any content. |
Accessibility
- role menu and menuitem; Escape and outside click close.
- Destructive items go last, after a divider.
Do and don't
- Do: "Open Claim, Check Status, Assign to Me, divider, Void Claim".
- Don't: More than about 8 items.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items * | MenuItem[] | — | Array<{label, icon?, hint?, shortcut?, danger?, disabled?, active?, onSelect?} | {divider:true} | {heading}>; required |
align | MenuAlign | 'right' | 'right' | 'left': which edge of the trigger the dropdown lines up with |
inline | boolean | false | Static, in-flow menu for docs and previews |
label | string | none | aria-label of the menu |
onItemSelect | (item: MenuActionItem, index: number) => void | none | Called with the chosen item and its index, after the item's own onSelect (one handler for every item) |
onClose | () => void | none | Called after an item is chosen, and on Escape or Tab inside the menu |
autoFocus | MenuFocusTarget | false | Moves focus to the first or last item on mount (used by menu buttons) |
style | CSSProperties | — | Inline style of the menu |
Also accepts native attributes, including defaultChecked, defaultValue, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-menu>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-menu align="…" inline [items]="items" (co-item-select)="onItemSelect($event.detail)"></co-menu>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | items | Array<{label, icon?, hint?, shortcut?, danger?, disabled?, active?, onSelect?} | {divider:true} | {heading}>; required |
| attribute | align | 'right' | 'left': which edge of the trigger the dropdown lines up with; default 'right' |
| attribute | inline | Static, in-flow menu for docs and previews; default false |
| attribute | label | aria-label of the menu; default none |
| property / JSON attribute | auto-focus / autoFocus | Moves focus to the first or last item on mount (used by menu buttons); default false |
| property / JSON attribute | style | Inline style of the menu |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| event | co-item-select | Called with the chosen item and its index, after the item's own onSelect (one handler for every item); default none (React: onItemSelect) |
| event | co-close | Called after an item is chosen, and on Escape or Tab inside the menu; default none (React: onClose) |