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-describedbystringNoaria—Accessible description id(s) for the menu panel.
aria-labelstringNoaria"Context menu"Accessible label for the menu panel.
aria-labelledbystringNoaria—Accessible labelledby target for the menu panel.
childrenReactNodeNoprops—Context target content. Used when opening by click or context menu.
classNamestringNostyling—Optional class name for the outer wrapper.
closeOnSelectbooleanNopropstrueWhether the menu closes after selecting a non-submenu item.
data-testidstringNotesting—Backward-compatible alias for test ID attributes.
defaultOpenbooleanNopropsfalseInitial open state for uncontrolled usage.
focusFirstItemOnOpenbooleanNopropstrueWhether focus moves to the first enabled item when the menu opens.
idstringNoprops—Optional id for the outer wrapper.
itemClassNamestringNoprops—Optional class name merged onto every actionable menu item.