JGuang

Menu

Menu · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Menu

A component to organize, arrange, and display a list of options.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Horizontal: By setting mode to horizontal, you can use the horizontal menu.
  • Dark Theme: The theme is specified by theme, which can be divided into two types: light and dark.
  • Collapsed Menu: Use collapse to specify the menu to collapse. Use renderItemInTooltip to specify the content of the menu item displayed in Tooltip when the menu is collapsed.
  • Sub Menu: Multiple sub-items can be embedded in the menu, and the items that are opened by default can be set through defaultOpenKeys.
  • Custom Size: Freely specify width of menu and height of menu item through style.
  • Floating Menu: Specify mode as pop to use floating menu.
  • Floating Button Menu: By setting mode to popButton, you can use a button group style floating menu.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

PropertyDescriptionTypeDefaultValueVersion
accordionWhether to render as Accordionboolean--
autoOpenWhether to expand all multi-level menus by defaultboolean--
autoScrollIntoViewWhether to automatically scroll the selected item to the visible areaboolean--
collapseWhether to collapse the menu horizontallyboolean--
hasCollapseButtonWhether built-in folding buttonboolean--
selectableWhether is the menu item selectablebooleantrue-
levelIndentIndentation between levelsnumber--
modeMode of Menu'vertical' | 'horizontal' | 'pop' | 'popButton'vertical-
themeTheme of Menu'light' | 'dark'light-
classNameAdditional css classstring | string[]--
defaultOpenKeysThe initially opened menu item's key arraystring[]--
defaultSelectedKeysThe initially selected menu item's key arraystring[]--
ellipsisWhether the horizontal menu automatically collapses when it overflows| boolean| {text?: ReactNode;}true2.24.0
iconsCustomize icons{horizontalArrowDown?: ReactNode | null;popArrowRight?: ReactNode | null;collapseDefault?: ReactNode | null;collapseActive?: ReactNode | null;}--
openKeysOpened menu item's key arraystring[]--
scrollConfigScroll to the configuration item in the visible area and receive all the parameters ofscroll-into-view-if-needed{ [key: string]: any }--
selectedKeysSelected menu item's key arraystring[]--
styleAdditional styleCSSProperties--
tooltipPropsPass all Tooltip component propertiesPartial<TooltipProps>--
triggerPropsPass all Trigger component propertiesPartial<TriggerProps>--
onClickMenuItemClick menu item callback(key: string, event, keyPath: string[]) => any-event in 2.15.0, keyPath in 2.19.0
onClickSubMenuCallback when click sub menu(key: string, openKeys: string[], keyPath: string[]) => void-keyPath in 2.19.0
onCollapseChangeCallback when menu collapse status changed(collapse: boolean) => void--
onEllipsisChangeCallback when horizontal-menu ellipsis status changed(status: { lastVisibleIndex: number; overflowNodes: ReactNode[] }) => void-2.57.0
PropertyDescriptionTypeDefaultValueVersion
selectableWhether to use the subMenu header as a menu item which can be selectedboolean--
keyUnique ID of the subMenustring (Required)--
titleTitle of the subMenustring | ReactNode--
classNameAdditional css classstring | string[]--
styleAdditional styleCSSProperties--
triggerPropsPass all Trigger component propertiesPartial<TriggerProps>-2.19.0
popupWhether to force the use of popup mode, parameter level indicates the level of current subMenu.boolean | ((level: number) => boolean)-2.8.0
PropertyDescriptionTypeDefaultValue
titleTitle of the menu item groupstring | ReactNode-
classNameAdditional css classstring | string[]-
styleAdditional styleCSSProperties-
PropertyDescriptionTypeDefaultValueVersion
disabledWhether the item is disabledboolean--
keyUnique ID of the menu itemstring (Required)--
classNameAdditional css classstring | string[]--
styleAdditional styleCSSProperties--
wrapperConfigure the outermost label, which can be a html label or a componentstring | React.FC<any> | React.ComponentClass<any>div2.16.0
renderItemInTooltipSet the menu item displayed in Tooltip when menu is collapsed() => ReactNode-2.51.0