Skip to content

Menu

Roving keyboard navigation for commands. Custom element

Menu
Copy this markup
<ui-menu role="menu" aria-label="Editor commands">
<button role="menuitem" type="button">Duplicate</button>
<button role="menuitem" type="button">Archive</button>
<button role="menuitem" type="button" disabled>Delete</button>
</ui-menu>

Install

Styles and registration
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/button.css'
import '@timelessui/components/css/menu.css'
import '@timelessui/components/define/ui-menu'

Anatomy

Parts are authored in your own markup and identified by the selector below, so your CSS can target the same anatomy without loading Timeless styles. Required parts must be present for the component to work. Private data-ui-internal-* hooks are written by the runtime and must never be authored.

PartRequiredSelectorPurpose
menuYes[role='menu']The menu container. Use role="menubar" for a persistent horizontal menu bar.
itemYes[role^='menuitem']One command. Use role="menuitem", or menuitemcheckbox / menuitemradio with aria-checked. Timeless manages roving tabindex and typeahead.

Attributes

Every value below is implemented by the stylesheets this component ships. Boolean attributes are presence-based: author the attribute with no value, or omit it.

AttributeValuesDefaultDescription
orientationhorizontal · verticalverticalArrow-key axis. Defaults to horizontal when the menu part is role="menubar".

Element API

Attributes above are the authoring surface. These are the DOM properties and events the registered element adds once it upgrades.

<ui-menu>

PropertyTypeNotes
orientation'horizontal' | 'vertical'Reflects the orientation attribute, documented above.

This element dispatches no component events.

Styling

Root identity: ui-menu. Required stylesheets: tokens.css, button.css, menu.css.

This component adds no custom properties of its own. Restyle it through the design tokens or your own CSS.

Design tokens this component reads (31)

These are global Atmosphere tokens. Change them once at the theme level rather than per component.

--ui-accent · --ui-accent-soft · --ui-bg-accent · --ui-bg-accent-active · --ui-bg-accent-hover · --ui-bg-control · --ui-bg-control-active · --ui-bg-control-hover · --ui-bg-control-muted · --ui-bg-danger · --ui-bg-danger-active · --ui-bg-danger-hover · --ui-bg-surface · --ui-bg-surface-raised · --ui-disabled-opacity · --ui-duration-fast · --ui-ease-standard · --ui-fg · --ui-focus · --ui-line · --ui-radius-control · --ui-radius-lg · --ui-radius-sm · --ui-shadow-control-accent · --ui-shadow-control-active · --ui-shadow-control-danger · --ui-shadow-floating · --ui-shadow-outline-control · --ui-space-1 · --ui-space-2 · --ui-space-3

Accessibility

Keep the native elements, roles, and relationships shown in the example. Timeless adds only the state and keyboard coordination the platform does not already provide, and it never supplies your accessible names — those depend on your content.

Follows the Menu and Menubar pattern from the ARIA Authoring Practices Guide.

KeyAction
Arrow keysMove focus between items along the orientation axis.
Home / EndMove focus to the first or last enabled item.
Enter / SpaceActivate the focused item.
EscapeClose the menu and return focus to whatever opened it.
Printable charactersTypeahead: jump to the next item whose label starts with what you typed.

The menu is one tab stop and disabled items are skipped. Typeahead matching is locale-aware.

Before JavaScript runs

The markup above is complete and usable on its own: native controls submit, labels associate, and authored ARIA is already correct. Registration adds state synchronisation, focus management, and keyboard coordination on top of it.

More examples

Open Menu in StoryLite for variants, controls, and manual testing.