Menu

The Menu allows construction of contextual menus with various options.

Usage & Examples

Default

default.tsx
<Menu
              trigger={<Button>Open Menu</Button>}
              activation="click"
              aria-label="View options"
              items={[
                { type: "label", label: "File" },
                {
                  label: "Rename",
                  icon: <FaEdit />,
                  shortcut: "Enter",
                  onClick: () => alert("Rename"),
                },
                {
                  label: "Duplicate",
                  icon: <FaCopy />,
                  shortcut: "Ctrl+D",
                  onClick: () => alert("Duplicate"),
                },
                { type: "separator" },
                {
                  label: "Move to",
                  icon: <FaFolderOpen />,
                  submenuAriaLabel: "Move destinations",
                  items: [
                    { label: "Backlog", onClick: () => alert("Backlog") },
                    { label: "In review", onClick: () => alert("In review") },
                    {
                      label: "Archive",
                      items: [
                        {
                          label: "This month",
                          onClick: () => alert("This month"),
                        },
                        { label: "All time", onClick: () => alert("All time") },
                      ],
                    },
                  ],
                },
                { type: "separator" },
                {
                  label: "Delete",
                  icon: <FaTrash />,
                  destructive: true,
                  onClick: () => alert("Delete"),
                },
              ]}
            ></Menu>

Props API

29 props
Columns
Menu props API
Default
Description
activationMenuActivationNopropstrigger ? "click" : "contextmenu"How the menu opens. Defaults to "click" when `trigger` is provided, otherwise "contextmenu".
aria-describedbystringNoariaAccessible description id(s) for the menu panel.
aria-labelstringNoaria"Context menu"Accessible label for the menu panel.
aria-labelledbystringNoariaAccessible labelledby target for the menu panel.
childrenReactNodeNopropsContext target content. Used when opening by click or context menu.
classNamestringNostylingOptional class name for the outer wrapper.
closeOnSelectbooleanNopropstrueWhether the menu closes after selecting a non-submenu item.
data-testidstringNotestingBackward-compatible alias for test ID attributes.
defaultOpenbooleanNopropsfalseInitial open state for uncontrolled usage.
focusFirstItemOnOpenbooleanNopropstrueWhether focus moves to the first enabled item when the menu opens.
glassbooleanNopropsconfigured default glass setting (fallback: false)Adds glass styling to the menu panel.
idstringNopropsOptional id for the outer wrapper.