Design System

Menu reference ​

Every prop, event, slot, attribute and measured value on the two menu wrappers. For which one to use, see Usage. Values were measured at the default interface text size, where the root is 14px.

CMenu props ​

PropTypeRequiredDefaultMeaning
model(T | CMenuSection<T>)[], T extends MenuItemYesNoneThe rows, in order. An entry carrying an items array becomes a section, and an empty array still draws the heading

CMenuProps<T> declares that one field. CMenuSection<T> is Omit<MenuItem, "items"> & { items: T[] }.

CContextMenu props ​

CContextMenu declares no props. Items arrive through the event bus behind useContextMenu().

Item fields ​

Fields the library reads from an entry in model, and from an entry passed to show.

FieldTypeEffect
labelstring or () => stringThe row text, and the accessible name on the row element
iconstringIcon class names, drawn before the label
command({ originalEvent, item }) => voidRuns when the row is picked
disabledboolean or () => booleanBlocks pointer events and sets aria-disabled
visibleboolean or () => booleanA value of false removes the row
separatorbooleanDraws a rule instead of a row
url, targetstringRenders the row as a link, in CMenu only
itemsAn array of itemsA flat section in CMenu, a flyout in CContextMenu
class, stylestring, an objectApplied to the row element by the library
shortcut() => string | undefinedTrailing text, read by CContextMenu only

ContextMenuItem also intersects Record<string, unknown>, so a misspelled field passes typecheck and does nothing.

Events ​

NamePayloadNotes
command on the item{ originalEvent: Event, item: MenuItem }, with id as well in CMenuNot a Vue event. The callback belongs to the row
focusFocusEventForwarded rather than declared, emitted by the list element
blurFocusEventForwarded rather than declared
show, hideNoneDeclared by the library and fired from the overlay transition. CContextMenu fires them as the overlay opens and closes, and a CMenu in flow never runs that transition
before-show, before-hideNoneDeclared by the library, reached through CContextMenu only

Slots ​

SlotComponentPropsNotes
startCMenuNoneRenders above the list, in a wrapper the preset leaves unstyled
itemCMenuitem, label, propsprops carries action, label and, at runtime only, icon
DefaultNeitherNoneChildren written between the tags are discarded
end, submenulabel, submenuheader, itemicon, submenuiconNeitherNoneSupported by the library, not forwarded by either wrapper

CContextMenu fills the item slot itself and does not expose it.

Sizes and severities ​

AxisAccepted
size, severity, variant, densityNeither wrapper declares any of them
StatesFocus, hover, active and disabled, all set by the library rather than by a caller

Attributes ​

AttributeCMenuCContextMenu
data-*Forwarded to the root elementApplied to the root element
aria-*Forwarded, with aria-label and aria-labelledby landing on the listApplied to the root element, apart from those two, which the library takes as props
on[A-Z] listenersForwarded to the root elementApplied to the root element
id, name, formForwarded, and id overrides the generated root idApplied to the root element
class, styleDroppedApplied to the root element
Library props such as popup, appendTo, tabindexDroppedReach the library component, which consumes the ones it declares

CMenu sets inheritAttrs: false and forwards what matches /^(data-|aria-|on[A-Z])|^(id|name|form)$/. Its own root classes are fixed in the template. CContextMenu inherits attributes and binds them a second time, so an attribute written on it lands twice.

DOM and ARIA ​

ElementSectionRole and attributes
divrootRendered in flow by CMenu, which carries the generated id here, and at the document body by CContextMenu, which carries it on the list instead
divstartPresent in CMenu only when the slot is given
ullist, rootListrole="menu" in CMenu, role="menubar" with aria-orientation="vertical" in CContextMenu, tabindex="0", aria-activedescendant, aria-label, aria-labelledby
liitemrole="menuitem", aria-label, aria-disabled, data-p-focused, data-p-disabled, and in CContextMenu also aria-haspopup, aria-expanded, aria-level, aria-setsize, aria-posinset, data-p-active
divitemContentCarries the click and pointer handlers and the row background
aitemLinkhref, target, tabindex="-1". Drawn by CMenu only when the item slot is absent, and the slot receives the same props plus aria-hidden
lisubmenuLabelrole="none", one per CMenu section
ulsubmenurole="menu", aria-labelledby, in CContextMenu only
liseparatorrole="separator"

Geometry ​

PartCMenuCContextMenu
Panel minimum width175px175px
Panel padding4px4px
Panel radius6px6px
Panel borderNone1px line-default
Panel backgroundTransparentsurface-page
ShadowNoneNone
Row height33px32px
Gap between rows2px, and none above the first4px, and none above the first
Row radius4px4px
Row padding8px and 12px6px and 16px
Gap after the icon8px8px
Trailing shortcut boxNot applicable8px, reserved whether or not shortcut is set
Section label20px tall, regular weight, no paddingNot applicable
FlyoutNot applicableFit-content up to 300px, scrolling past 384px
LayerIn flowAn inline z-index seeded from the floating layer, 101 for the first overlay opened

The row gaps differ because the CMenu list is a block container, where the 2px margins between rows collapse, and the CContextMenu list is a flex column, where they add up.

What not to write ​

Do not writeWhyWrite instead
A class or a style on CMenuBoth are dropped before they reach the DOMA class on the wrapper that holds the menu
popup on CMenuIt is dropped, so the list stays in flowA popover around the menu
<CContextMenu> with content insideThere is no default slot, so the content is discardeduseContextMenu().show(event, items)
A second CContextMenuThe shell already mounts the one instanceThe handle returned by useContextMenu()
items: [] on an itemIt draws a caret that opens nothingNo items field at all
shortcut: "Ctrl K"The field is a functionshortcut: () => "Ctrl K"
props.icon in the CMenu item slotIt exists at runtime but not in the declared typeitem.icon