Skip to main content

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​

Storybook

With Shortcuts​

Storybook

Kebab​

Storybook

Popover Filters​

Storybook

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​

VariantWhat it is
MenuItems with icon, hint, shortcut; heading, divider, danger item, disabled item, active item.
KebabMenuVertical or horizontal dots.
PopoverTitled 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​

PropTypeDefaultDescription
items *MenuItem[]—Array<{label, icon?, hint?, shortcut?, danger?, disabled?, active?, onSelect?} | {divider:true} | {heading}>; required
alignMenuAlign'right''right' | 'left': which edge of the trigger the dropdown lines up with
inlinebooleanfalseStatic, in-flow menu for docs and previews
labelstringnonearia-label of the menu
onItemSelect(item: MenuActionItem, index: number) => voidnoneCalled with the chosen item and its index, after the item's own onSelect (one handler for every item)
onClose() => voidnoneCalled after an item is chosen, and on Escape or Tab inside the menu
autoFocusMenuFocusTargetfalseMoves focus to the first or last item on mount (used by menu buttons)
styleCSSProperties—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>
KindNameDescription
property / JSON attributeitemsArray<{label, icon?, hint?, shortcut?, danger?, disabled?, active?, onSelect?} | {divider:true} | {heading}>; required
attributealign'right' | 'left': which edge of the trigger the dropdown lines up with; default 'right'
attributeinlineStatic, in-flow menu for docs and previews; default false
attributelabelaria-label of the menu; default none
property / JSON attributeauto-focus / autoFocusMoves focus to the first or last item on mount (used by menu buttons); default false
property / JSON attributestyleInline style of the menu
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
eventco-item-selectCalled with the chosen item and its index, after the item's own onSelect (one handler for every item); default none (React: onItemSelect)
eventco-closeCalled after an item is chosen, and on Escape or Tab inside the menu; default none (React: onClose)