logo

SINGULARITY

DOCS

PurchaseReturn to the Dashboard
Reference

Menu

Menus present a selection of options on temporary surfaces.

A menu showcases a list of options on a transient surface, appearing when a user engages with a button or another control.

Introduction

Menus are constructed using a set of interconnected components:
  • Menu: The container or surface that holds the menu.
  • Menu Item: An individual option available for user selection within the menu.
  • Menu List (optional): An alternative, composable container for Menu Items—refer to Composition with Menu List for more information.

Basic menu

By default, a basic menu appears over its anchor element (this behavior can be adjusted via props). When near a screen edge, it realigns vertically to ensure all menu items are fully visible.
The component should be set up so that choosing an option immediately confirms the selection and closes the menu, as demonstrated below.

Icon menu

In desktop viewports, the menu's padding is expanded to provide additional space.

Dense menu

For menus with lengthy lists or extended text, the dense prop can be used to minimize padding and font size.

Selected menu

When used for item selection, simple menus focus on the selected menu item upon opening. The selected item is defined using the selected prop (from ListItem). To use a selected item without affecting initial focus, set the variant prop to "menu".

Positioned menu

Since the Menu component leverages the Popover component for positioning, you can utilize the same positioning props to adjust its placement. For example, you can position the menu above the anchor.

Composition with Menu List

The Menu component internally uses the Popover component. However, you may prefer an alternative positioning approach or want to avoid blocking scrolling.
The MenuList component enables custom menu composition for such scenarios, primarily handling focus management. The example below demonstrates composition using MenuList with a Popper component instead of the default Popover.

Account menu

The content of a Menu can be combined with other components, such as Avatar.

Contact

Profile

Customization

This example illustrates how to customize the component. Learn more in the overrides documentation page.
The MenuItem component wraps ListItem with added styles. You can leverage the same list composition features with the MenuItem component.
🎨 For inspiration, explore MUI Treasury's customization examples.

Max height menu

When a menu's height prevents all items from being shown, it can scroll internally.

Limitations

A flexbox bug prevents text-overflow: ellipsis from functioning in a flexbox layout. You can bypass this issue by using the Typography component with the noWrap prop.

Change transition

Apply a different transition effect.

Context menu

This example demonstrates a context menu, accessible via a right-click.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ipsum purus, bibendum sit amet vulputate eget, porta semper ligula. Donec bibendum vulputate erat, ac fringilla mi finibus nec. Donec ac dolor sed dolor porttitor blandit vel vel purus. Fusce vel malesuada ligula. Nam quis vehicula ante, eu finibus est. Proin ullamcorper fermentum orci, quis finibus massa. Nunc lobortis, massa ut rutrum ultrices, metus metus finibus ex, sit amet facilisis neque enim sed neque. Quisque accumsan metus vel maximus consequat. Suspendisse lacinia tellus a libero volutpat maximus.

Grouped Menu

Organize items into categories using the ListSubheader component.

Supplementary projects

For advanced use cases, you can benefit from the following resources:

material-ui-popup-state

starsnpm downloads
The material-ui-popup-state package simplifies menu state management in most scenarios.