MenuItem API
API reference docs for the React MenuItem component. Learn about the props, CSS, and other APIs of this exported module.
Demos
Import
import MenuItem from '@mui/joy/MenuItem';
// or
import { MenuItem } from '@mui/joy';
Learn about the difference by reading this guide on minimizing bundle size.
Name | Type | Description |
---|---|---|
children | node | The content of the component. |
ref
is forwarded to the root element.Inheritance
While not explicitly documented above, the props of the ListItemButton component are also available in MenuItem. You can take advantage of this to target nested components.
Theme default props
You can use JoyMenuItem
to change the default props of this component with the theme.
To learn how to customize the slot, check out the Overriding component structure guide.
Slot name | Class name | Default component | Description |
---|---|---|---|
root | .MuiMenuItem-root | 'div' | The component that renders the root. |
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
Class name | Rule name | Description |
---|---|---|
.Mui-disabled | State class applied to the inner component element if disabled={true} . | |
.Mui-focusVisible | State class applied to the component 's focusVisibleClassName prop. | |
.Mui-selected | State class applied to the root element if selected={true} . | |
.MuiMenuItem-colorContext | colorContext | Class name applied to the root element when color inversion is triggered. |
.MuiMenuItem-colorDanger | colorDanger | Class name applied to the root element if color="danger" . |
.MuiMenuItem-colorNeutral | colorNeutral | Class name applied to the root element if color="neutral" . |
.MuiMenuItem-colorPrimary | colorPrimary | Class name applied to the root element if color="primary" . |
.MuiMenuItem-colorSuccess | colorSuccess | Class name applied to the root element if color="success" . |
.MuiMenuItem-colorWarning | colorWarning | Class name applied to the root element if color="warning" . |
.MuiMenuItem-variantOutlined | variantOutlined | State class applied to the root element if variant="outlined" . |
.MuiMenuItem-variantPlain | variantPlain | State class applied to the root element if variant="plain" . |
.MuiMenuItem-variantSoft | variantSoft | State class applied to the root element if variant="soft" . |
.MuiMenuItem-variantSolid | variantSolid | State class applied to the root element if variant="solid" . |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.