Skip to main content

Menu Item Styles

The menuItemStyles prop allows you to customize the style of the menu items.

Propsโ€‹

type MenuItemStyles = {
root?: ElementStyles;
button?: ElementStyles;
label?: ElementStyles;
prefix?: ElementStyles;
suffix?: ElementStyles;
icon?: ElementStyles;
subMenuContent?: ElementStyles;
subMenuExpandIcon?: ElementStyles;
};

type ElementStyles =
| CSSObject
| ((params: MenuItemStylesParams) => CSSObject | undefined);

type MenuItemStylesParams = {
level: number;
disabled: boolean;
active?: boolean;
isSubmenu: boolean;
open?: boolean;
};

The MenuItemStyles object allows you to customize the style of various elements within the menu item. Each property corresponds to a specific element and accepts a CSSObject that contains the styles.

PropertyDescription
rootThe root element of all the menu-items and submenus.
buttonThe button element of all the menu-items and submenus.
labelThe label element of all the menu-items and submenus.
prefixThe prefix element of all the menu-items and submenus.
suffixThe suffix element of all the menu-items and submenus.
iconThe icon element of all the menu-items and submenus.
subMenuContentThe content of sub menu element of all the submenus.
subMenuExpandIconThe expand icon of sub menu element of all the submenus.

The MenuItemStylesParams object contains the following properties:

PropertyDescription
levelThe depth level of the menu item.
disabledWhether the menu item is disabled.
activeWhether the menu item is active.
isSubmenuWhether the menu item is a submenu.
openWhether the submenu associated with the menu item is open or closed.

You can customize these styles by providing a CSSObject with appropriate style properties.

With Parameterโ€‹

The menuItemStyles prop takes a MenuItemStylesParams object as a parameter. This allows you to apply styles based on different conditions.

By using the MenuItemStylesParams object, you can dynamically apply styles based on the provided parameters.

Exampleโ€‹

/vertical-menu/menu/menu-item-styles/with-params

Source Codeโ€‹


Without Parameterโ€‹

The menuItemStyles prop directly returns a CSSObject without any parameters.

Exampleโ€‹

/vertical-menu/menu/menu-item-styles/without-params

Source Codeโ€‹