Skip to content

CSS: menu ​

.instui-menu — A dropdown surface of items, groups, and separators.

Keyboard navigation is opt-in: add data-menu-navigation to a vertical native popover with role="menu" and load @pantoken/interactions/menu.iife.js, or call initMenu(menu, button). Use one native button[popovertarget]. The behavior handles focus, arrows, Home/End, initial-character search, Escape, and activation; applications own actions and checked state. Submenus and menubars aren't supported.

Source: group.css

TIP

JS Enhancement — This component's CSS renders and works on its own; pair it with @pantoken/interactions to add the interactive behavior. See the modifier table below.

Usage ​

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/menu.css";

Demo ​

Examples ​

html
<button class="instui-button" type="button" popovertarget="docs-actions-menu" aria-haspopup="menu" aria-controls="docs-actions-menu" aria-expanded="false">Actions</button>
<div class="instui-menu" id="docs-actions-menu" popover="auto" role="menu" aria-label="Actions" data-menu-navigation>
  <button class="item" type="button" role="menuitem">Edit</button>
  <button class="item" type="button" role="menuitem">Delete</button>
</div>

Structure ​

text
.instui-menu
  menu.group (component, 0..1)
  side-nav-bar.item (component, 0..n)
  menu.separator (component, 0..1)
flowchart TD n0[".instui-menu"]:::cssdoc-root n1(["menu.group"]):::cssdoc-component n2(["side-nav-bar.item"]):::cssdoc-component n3(["menu.separator"]):::cssdoc-component n0 -.->|0..1| n1 n0 -->|0..n| n2 n0 -.->|0..1| n3 click n1 "/api/css/menu.group.md" click n2 "/api/css/side-nav-bar.item.md" click n3 "/api/css/menu.separator.md" classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

Accessibility ​

Name the menu and button. Use menuitem for actions, menuitemcheckbox/menuitemradio with aria-checked for checked actions, and separator for dividers. Add aria-disabled="true" to disabled items; a CSS modifier alone doesn't convey disabled state. ARIA-disabled entries remain focusable but cannot activate; native-disabled and hidden entries are skipped.

Rules (axe-core)Rebrand (light)Rebrand (dark)CanvasCanvas High Contrast
aria-valid-attr-valueWCAG 2.2 4.1.2Review neededReview neededReview neededReview needed

ARIA attributes must conform to valid values

  • button[popovertarget="actions-menu"]
ConditionsRebrand (light)Rebrand (dark)CanvasCanvas High Contrast
forced-colors-focus-visibleWCAG 2.2 1.4.11, 2.4.7PassPassPassPass
less-contrast-stays-readableWCAG 2.2 1.4.3PassNot applicableNot applicableNot applicable
more-contrast-respectedWCAG 2.2 1.4.3, 1.4.6PassPassPassPass
reduced-motion-respectedWCAG 2.2 2.3.3, 2.2.2PassPassPassPass
reflow-at-320pxWCAG 2.2 1.4.10PassPassPassPass
text-spacing-no-clippingWCAG 2.2 1.4.12PassPassPassPass
InteractionsRebrand (light)Rebrand (dark)CanvasCanvas High Contrast
arrow-keys-move-between-itemsWCAG 2.2 2.1.1PassPassPassPass
escape-closes-and-returns-focusWCAG 2.2 2.1.1, 2.4.3PassPassPassPass
focus-indicator-visibleWCAG 2.2 2.4.7PassPassPassPass
no-focus-trapWCAG 2.2 2.1.2PassPassPassPass
opens-with-enter-or-arrowWCAG 2.2 2.1.1PassPassPassPass
trigger-reachable-by-tabWCAG 2.2 2.1.1PassPassPassPass
Computed stylesRebrand (light)Rebrand (dark)CanvasCanvas High Contrast
boundary-contrastWCAG 2.2 1.4.11PassPassPassPass
focus-indicator-contrastWCAG 2.2 1.4.11, 2.4.13PassPassPassPass
text-contrast-by-stateWCAG 2.2 1.4.3PassPassPassPass
Screen reader (simulated)Rebrand (light)Rebrand (dark)CanvasCanvas High Contrast
AnnouncementsPassPassPassPass

These automated results do not establish that the page meets WCAG; manual review is still needed.

Tokens consumed ​

TokenTypeValue
--instui-border-radius-md<length>0.5rem
--instui-border-width-sm<length>0.0625rem
--instui-color-stroke-base<color>LightDarklight-dark(#8D959F, #6A7883)
--instui-component-menu-item-background<color>LightDarklight-dark(#ffffff, #171B21)
--instui-component-menu-max-width<length>16em
--instui-component-menu-min-width<length>8em
--instui-spacing-space-xs<length>0.25rem

Subcomponents ​