New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

better-mui-menu

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-mui-menu

MUI Menu enhancement for deeply nested menus with keyboard navigation and accessibility in mind.

latest
Source
npmnpm
Version
1.5.2
Version published
Maintainers
3
Created
Source

better-mui-menu

CI Security coverage npm version npm downloads License: MIT

better-mui-menu is a zero-dependency wrapper for Material UI Menu to support nested menus and full keyboard accessibility with proper focus management.

Live demo

Edit better-mui-menu-demo

Edit in StackBlitz

Menu demo preview

Features

  • Excellent Keyboard Navigation for Accessibility – navigate with arrow keys, open submenus with right arrow or Enter, close them with left arrow or Escape, and have the menu stack stay in sync with focus.
  • Unlimited nesting – describe every submenu with an items array and better-mui-menu renders NestedMenuItem poppers that stay synchronized with their parents.
  • Customizable – style your menu and menu items using MUI's Menu and MenuItem props.
  • Data-driven API – you keep work in a single MenuItem[] list; leaves, dividers, and nested branches all live alongside each other.

Installation

(yarn | npm | pnpm) install better-mui-menu

Since the component renders Material UI primitives, also install the peer dependencies:

npm install @mui/material @emotion/react @emotion/styled @mui/icons-material

Usage

import { Menu, type MenuItem } from 'better-mui-menu'

const menuItems: MenuItem[] = [
  {
    id: 'save',
    label: 'Save',
    startIcon: Save,
    onClick: () => console.log('Save action'),
  },
  { type: 'divider' },
  {
    label: (
      <Stack>
        Cloud actions
        <Typography variant="caption" color="text.secondary">
          Requires internet connection
        </Typography>
      </Stack>
    ),
    startIcon: <Cloud fontSize='small' sx={{ ml: 0.5 }} />,
    items: [
      { label: 'Upload', onClick: () => console.log('Upload') },
      { label: 'Download', onClick: () => console.log('Download') },
    ],
  },
]

export function FileMenu() {
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)

  return (
    <>
      <Button variant="contained" onClick={event => setAnchorEl(event.currentTarget)}>
        Open file menu
      </Button>
      <Menu
        anchorEl={anchorEl}
        open={Boolean(anchorEl)}
        onClose={() => setAnchorEl(null)}
        items={menuItems}
      />
    </>
  )
}

MenuItem Reference

MenuItem extends @mui/material/MenuItemProps (excluding children) so you can still pass disabled, sx, aria-*, data-*, etc.

FieldApplies toType / valuesRequiredDefaultNotes
typeall entries'item' | 'divider' | 'header'no'item'Use 'divider' for separators, 'header' for section labels.
id'item'stringnoauto-generatedUsed for stable ARIA/menu item IDs.
label'item', 'header'text or JSXyes ('item', 'header')noneNot used for 'divider'.
startIcon'item'MUI Icon or JSXnononeExample: Save or <Save fontSize='small' />.
endIcon'item'MUI Icon or JSXnononeFor submenu triggers, a right-arrow icon is shown when omitted.
items'item'MenuItem[]nononeIf present and non-empty, renders a nested submenu.
onClick'item'functionnononeRuns on leaf item click; menu stack closes afterward.
...MenuItemProps'item'MUI MenuItem props (except children, type)noMUI defaultsExample: disabled, dense, selected, data-*.

Keywords

mui

FAQs

Package last updated on 04 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts