- Docs
- Components
- Overlays
Menu
Actions in a list, from a button: arrows move, typing jumps, Escape closes. It never traps Tab.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<div role="menu">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// From the package: a build keeps only what it uses.
import { Menu, MenuTrigger, MenuContent, MenuItem, MenuSeparator } from "@qeetrix/react";
// Or from its own path.
import { Menu, MenuTrigger, MenuContent, MenuItem, MenuSeparator } from "@qeetrix/react/menu";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
Menu: open · defaultOpen · onOpenChange | boolean | false | Its open state. |
MenuTrigger: render | ReactElement | — | Your own control: an IconButton named for its object. |
MenuContent: side · align · sideOffset | … | "bottom" · "start" · 4 | A submenu opens at the inline end; a context menu at the pointer. |
MenuItem: icon · shortcut · description | … | — | A leading icon; a key at the end; a second line. |
MenuItem: tone | "default" | "danger" | "default" | danger for a destructive action: last, after a separator. |
MenuItem: onClick · disabled | … | — | The action; or shown but not chosen. |
MenuCheckboxItem: checked · onCheckedChange | boolean | — | An option on or off, with a sharp check. |
MenuRadioGroup: value · onValueChange | string | — | MenuRadioItem choices, with a 6px dot. |
MenuRadioItem: closeOnClick | boolean | true | Closes the menu on a choice; false where several settings change in a row. |
MenuGroup · MenuGroupLabel · MenuSeparator | … | — | Labelled groups and the rules between them. |
MenuSubmenu · MenuSubmenuTrigger | … | — | A nested menu: its trigger has a chevron that mirrors in right to left. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
menu-popup | <div role="menu"> | The list. |
menu-item | <div role="menuitem"> | An action: data-highlighted, data-tone. |
menu-item-icon | <svg> | Its icon. |
menu-item-text | <span> | menu-item-label and menu-item-description. |
menu-shortcut | <span> | Its key. |
menu-checkbox-item · menu-radio-item | <div> | With menu-item-mark: the check or the dot. |
menu-separator · menu-group-label | <div> | Between groups, and above one. |
menu-submenu-trigger | <div> | With menu-submenu-icon, the chevron. |
04
Name the trigger for its row
Every row's ⋯ says whose actions it opens.
<MenuTrigger render={<IconButton icon={EllipsisIcon} aria-label={`Actions for ${member.name}`} tone="neutral" />} />