Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

Menu

  • Stable
  • WCAG 2.2 evidence
  • RTL
  • Web · iOS · Android

A list of actions or options that opens from a trigger. Built on React Aria MenuTrigger + Popover + Menu: the trigger gets aria-haspopup and aria-expanded; Enter, Space and the arrow keys open the menu with focus on the first (or last) item; arrows, Home/End and type-ahead move focus; Escape closes it and returns focus to the trigger; submenus open with the arrow key that points into them (mirrored in RTL) (WCAG 2.1.1, 2.4.3, 4.1.2). Long menus scroll inside the surface, which flips to stay in the viewport. Two ways to use it: pass trigger (simple), or compose MenuTrigger > trigger + Menu, and SubmenuTrigger > MenuItem + Menu for submenus. Put primary, frequent actions on buttons instead.

import { Menu } from "@nexera-ui/react";
Loading example…
5
examples
28
props
3
live controls
3
platforms
7
WCAG criteria
2
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
platform
placement
defaultOpen
Generated code
import { Menu } from "@nexera-ui/react";

<Menu />

Examples 4

The same examples as Storybook, rendered live. Open Code to copy one.

Sections and selection

Composable form: MenuTrigger > trigger + Menu, sections with MenuSectionLabel, and single selection.

Loading example…

Controlled

Controlled open state: isOpen and onOpenChange.

Loading example…

Long menu

Long menus scroll inside the surface; the focused item is scrolled into view with room for its focus ring.

Loading example…

Platforms

Figma System menu: the same menu on iOS (250 pt, radius 14, group separators) and Android (220 dp, radius 4).

Loading example…

Props 28

Press "Try it" on a card to load that prop into the playground.

28 props shown

platformNexera
"web" | "ios" | "android"

Platform look. Items, section labels and dividers inside follow it. Defaults to the enclosing menu (for submenus), then the NexeraProvider.

Default "web"
placementNexera
"bottom" | "bottom left" | "bottom right" | "bottom start" | "bottom end" | "top" | "top left" | "top right" | "top start" | "top end" | "left" | "left top" | "left bottom" | "start" | "start top" | "start bottom" | "right" | "right top" | "right bottom" | "end" | "end top" | "end bottom"

Where the menu opens relative to its trigger. It flips to stay inside the viewport. Submenus default to "end top", which mirrors in right-to-left layouts.

Default "bottom start"
classNameNexera
string

Extra classes for the menu surface, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style for the menu surface.

Default –
triggerNexera
ReactElement<unknown, string | JSXElementConstructor<any>>

The element that opens the menu, usually a Button or IconButton. React Aria gives it aria-haspopup, aria-expanded, and opens the menu on press, Enter, Space and the arrow keys. Without trigger, render the Menu as the second child of a MenuTrigger (or of a SubmenuTrigger for a submenu).

Default –
isOpenNexera
boolean

Whether the menu is open (controlled). Use with onOpenChange.

Default –
defaultOpenNexera
boolean

Whether the menu is open on first render (uncontrolled).

Default false
onOpenChangeNexera
(isOpen: boolean) => void

Called when the menu opens or closes.

Default –
childrenReact Aria
ReactNode | ((item: T) => ReactNode)

The contents of the collection.

Default –
escapeKeyBehaviorReact Aria
"clearSelection" | "none"

Whether pressing the escape key should clear selection in the menu or not. Most experiences should not modify this option as it eliminates a keyboard user's ability to easily clear selection. Only use if the escape key is being handled externally or should not trigger selection clearing contextually.

Default 'clearSelection'
autoFocusReact Aria
boolean | FocusStrategy

Where the focus should be set.

Default –
shouldFocusWrapReact Aria
boolean

Whether keyboard navigation is circular.

Default –
onActionReact Aria
(key: Key, value: T) => void

Handler that is called when an item is selected.

Default –
onCloseReact Aria
() => void

Handler that is called when the menu should close after selecting an item.

Default –
itemsReact Aria
Iterable<T>

Item objects in the collection.

Default –
disabledKeysReact Aria
Iterable<Key>

The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.

Default –
selectionModeReact Aria
"none" | "single" | "multiple"

The type of selection that is allowed in the collection.

Default –
disallowEmptySelectionReact Aria
boolean

Whether the collection allows empty selection.

Default –
selectedKeysReact Aria
Iterable<Key> | "all"

The currently selected keys in the collection (controlled).

Default –
defaultSelectedKeysReact Aria
Iterable<Key> | "all"

The initial selected keys in the collection (uncontrolled).

Default –
onSelectionChangeReact Aria
(keys: Selection) => void

Handler that is called when the selection changes.

Default –
idReact Aria
string

The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

Default –
aria-labelReact Aria
string

Defines a string value that labels the current element.

Default –
aria-labelledbyReact Aria
string

Identifies the element (or elements) that labels the current element.

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

Default –
renderEmptyStateReact Aria
() => ReactNode

Provides content to display when there are no items in the menu.

Default –
shouldCloseOnSelectReact Aria
boolean

Whether the menu should close when the menu item is selected.

Default –
dependenciesReact Aria
readonly any[]

Values that should invalidate the item cache when using dynamic collections.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

5 direct · 2 supporting
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.3.2Meaningful SequenceLevel A · tested directly
  • 1.4.10ReflowLevel AA · supporting test
  • 2.1.1KeyboardLevel A · tested directly
  • 2.3.3Animation from InteractionsLevel AAA · supporting test
  • 2.4.3Focus OrderLevel A · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

Usage
<Menu className="shadow-sm" />

Used in blocks

Related components