logoAnt Design

⌘ K
  • 디자인
  • 개발
  • 컴포넌트
  • 블로그
  • 자료
5.21.3
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
      5.13.0

Menu

A versatile menu for navigation.
가져오기import{ Menu }from"antd";
소스components/menu
문서
이 페이지 수정변경 로그

Resources

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
ahooks-React Hooks Library
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference
Work with Us

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

When To Use

Navigation is an important part of any website, as a good navigation setup allows users to move around the site quickly and efficiently. Ant Design offers two navigation options: top and side. Top navigation provides all the categories and functions of the website. Side navigation provides the multi-level structure of the website.

More layouts with navigation: Layout.

Notes for developers

  • Menu is rendered as a ul element, so it only supports li and script-supporting elements as children nodes。Your customized node should be wrapped by Menu.Item.
  • Menu needs to collect its node structure, so its children should be Menu.* or encapsulated HOCs.

Examples

API

Common props ref:Common props

Menu

ParamDescriptionTypeDefault valueVersion
defaultOpenKeysArray with the keys of default opened sub menusstring[]-
defaultSelectedKeysArray with the keys of default selected menu itemsstring[]-
expandIconcustom expand icon of submenuReactNode | (props: SubMenuProps & { isSubMenu: boolean }) => ReactNode-4.9.0
forceSubMenuRenderRender submenu into DOM before it becomes visiblebooleanfalse
inlineCollapsedSpecifies the collapsed status when menu is inline modeboolean-
inlineIndentIndent (in pixels) of inline menu items on each levelnumber24
itemsMenu item contentItemType[]-4.20.0
modeType of menuvertical | horizontal | inlinevertical
multipleAllows selection of multiple itemsbooleanfalse
openKeysArray with the keys of currently opened sub-menusstring[]-
overflowedIndicatorCustomized the ellipsis icon when menu is collapsed horizontallyReactNode<EllipsisOutlined />
selectableAllows selecting menu itemsbooleantrue
selectedKeysArray with the keys of currently selected menu itemsstring[]-
styleStyle of the root nodeCSSProperties-
subMenuCloseDelayDelay time to hide submenu when mouse leaves (in seconds)number0.1
subMenuOpenDelayDelay time to show submenu when mouse enters, (in seconds)number0
themeColor theme of the menulight | darklight
triggerSubMenuActionWhich action can trigger submenu open/closehover | clickhover
onClickCalled when a menu item is clickedfunction({ item, key, keyPath, domEvent })-
onDeselectCalled when a menu item is deselected (multiple mode only)function({ item, key, keyPath, selectedKeys, domEvent })-
onOpenChangeCalled when sub-menus are opened or closedfunction(openKeys: string[])-
onSelectCalled when a menu item is selectedfunction({ item, key, keyPath, selectedKeys, domEvent })-

More options in rc-menu

ItemType

type ItemType = MenuItemType | SubMenuType | MenuItemGroupType | MenuDividerType;

MenuItemType

ParamDescriptionTypeDefault valueVersion
dangerDisplay the danger stylebooleanfalse
disabledWhether menu item is disabledbooleanfalse
extraThe extra of the menu itemReactNode-5.21.0
iconThe icon of the menu itemReactNode-
keyUnique ID of the menu itemstring-
labelMenu labelReactNode-
titleSet display title for collapsed itemstring-

SubMenuType

PropertyDescriptionTypeDefault valueVersion
childrenSub-menus or sub-menu itemsItemType[]-
disabledWhether sub-menu is disabledbooleanfalse
iconIcon of sub menuReactNode-
keyUnique ID of the sub-menustring-
labelMenu labelReactNode-
popupClassNameSub-menu class name, not working when mode="inline"string-
popupOffsetSub-menu offset, not working when mode="inline"[number, number]-
themeColor theme of the SubMenu (inherits from Menu by default)light | dark-
onTitleClickCallback executed when the sub-menu title is clickedfunction({ key, domEvent })-

MenuItemGroupType

Define type as group to make as group:

const groupItem = {
type: 'group', // Must have
label: 'My Group',
children: [],
};
ParamDescriptionTypeDefault valueVersion
childrenSub-menu itemsMenuItemType[]-
labelThe title of the groupReactNode-

MenuDividerType

Divider line in between menu items, only used in vertical popup Menu or Dropdown Menu. Need define the type as divider:

const dividerItem = {
type: 'divider', // Must have
};
ParamDescriptionTypeDefault valueVersion
dashedWhether line is dashedbooleanfalse

FAQ

Why will Menu's children be rendered twice?

Menu collects structure info with twice-render to support HOC usage. Merging into one render may cause the logic to become much more complex. Contributions to help improve the collection logic are welcomed.

Why Menu do not responsive collapse in Flex layout?

Menu will render fully item in flex layout and then collapse it. You need tell flex not consider Menu width to enable responsive (online demo):

<div style={{ flex }}>
<div style={{ ... }}>Some Content</div>
<Menu style={{ minWidth: 0, flex: "auto" }} />
</div>

Design Token

컴포넌트 토큰어떻게 사용하나요?

토큰 이름설명타입기본값
activeBarBorderWidth菜单项指示条边框宽度string | number1
activeBarHeight菜单项指示条高度number2
activeBarWidth菜单项指示条宽度string | number0
collapsedIconSize收起时图标尺寸number16
collapsedWidth收起后的宽度string | number80
dangerItemActiveBg危险菜单项文字激活颜色string#fff2f0
dangerItemColor危险菜单项文字颜色string#ff4d4f
dangerItemHoverColor危险菜单项文字悬浮颜色string#ff4d4f
dangerItemSelectedBg危险菜单项文字选中颜色string#fff2f0
dangerItemSelectedColor危险菜单项文字选中颜色string#ff4d4f
darkDangerItemActiveBg暗色模式下的危险菜单项激活态背景string#ff4d4f
darkDangerItemColor暗色模式下的危险菜单项文字颜色string#ff4d4f
darkDangerItemHoverColor暗色模式下的危险菜单项悬浮文字背景string#ff7875
darkDangerItemSelectedBg暗色模式下的危险菜单项选中背景string#ff4d4f
darkDangerItemSelectedColor暗色模式下的危险菜单项选中文字颜色string#fff
darkGroupTitleColor暗色模式下的分组标题文字颜色stringrgba(255, 255, 255, 0.65)
darkItemBg暗色模式下的菜单项背景string#001529
darkItemColor暗色模式下的菜单项文字颜色stringrgba(255, 255, 255, 0.65)
darkItemDisabledColor暗色模式下的菜单项禁用颜色stringrgba(255, 255, 255, 0.25)
darkItemHoverBg暗色模式下的菜单项悬浮背景stringtransparent
darkItemHoverColor暗色模式下的菜单项悬浮颜色string#fff
darkItemSelectedBg暗色模式下的菜单项选中背景string#1677ff
darkItemSelectedColor暗色模式下的菜单项选中颜色string#fff
darkPopupBg暗色模式下的浮层菜单的背景颜色string#001529
darkSubMenuItemBg暗色模式下的子菜单项背景string#000c17
dropdownWidth弹出菜单的宽度string | number160
groupTitleColor分组标题文字颜色stringrgba(0, 0, 0, 0.45)
groupTitleFontSize分组标题文字大小number14
groupTitleLineHeight分组标题文字高度string | number1.5714285714285714
horizontalItemBorderRadius横向菜单项圆角number0
horizontalItemHoverBg横向菜单项横悬浮态背景色stringtransparent
horizontalItemHoverColor水平菜单项文字悬浮颜色string#1677ff
horizontalItemSelectedBg水平菜单项选中态背景色stringtransparent
horizontalItemSelectedColor水平菜单项文字选中颜色string#1677ff
horizontalLineHeight横向菜单行高undefined | LineHeight<string | number>46px
iconMarginInlineEnd图标与文字间距undefined | MarginInlineEnd<string | number>10
iconSize图标尺寸number14
itemActiveBg菜单项激活态背景色string#e6f4ff
itemBg菜单项背景色string#ffffff
itemBorderRadius菜单项的圆角number8
itemColor菜单项文字颜色stringrgba(0, 0, 0, 0.88)
itemDisabledColor菜单项文字禁用颜色stringrgba(0, 0, 0, 0.25)
itemHeight菜单项高度string | number40
itemHoverBg菜单项悬浮态背景色stringrgba(0, 0, 0, 0.06)
itemHoverColor菜单项文字悬浮颜色stringrgba(0, 0, 0, 0.88)
itemMarginBlock菜单项纵向外间距undefined | MarginBlock<string | number>4
itemMarginInline菜单项横向外间距number4
itemPaddingInline菜单项横向内间距undefined | PaddingInline<string | number>16
itemSelectedBg菜单项选中态背景色string#e6f4ff
itemSelectedColor菜单项文字选中颜色string#1677ff
popupBg弹出框背景色string#ffffff
subMenuItemBg子菜单项背景色stringrgba(0, 0, 0, 0.02)
subMenuItemBorderRadius子菜单项的圆角number4
zIndexPopup弹出菜单的 z-indexnumber1050

글로벌 토큰어떻게 사용하나요?

Top Navigation
codepen icon
External Link Icon
expand codeexpand code
Top Navigation (dark)
codepen icon
External Link Icon
expand codeexpand code
Inline menu
codepen icon
External Link Icon
expand codeexpand code
Collapsed inline menu
codepen icon
External Link Icon
expand codeexpand code
Open current submenu only
codepen icon
External Link Icon
expand codeexpand code
Vertical menu
codepen icon
External Link Icon
expand codeexpand code
Menu Themes
codepen icon
External Link Icon
expand codeexpand code
Sub-menu theme
codepen icon
External Link Icon
expand codeexpand code
Switch the menu type
codepen icon
External Link Icon
expand codeexpand code
Style debug
codepen icon
External Link Icon
expand codeexpand code
Menu v4
codepen icon
External Link Icon
expand codeexpand code
Component Token
codepen icon
External Link Icon
expand codeexpand code
  • Navigation One
  • Navigation Two
  • Navigation Three - Submenu
  • Navigation Four - Link
  • Navigation One
  • Navigation Two
  • Navigation Three - Submenu
  • Navigation Four - Link
  • Navigation One
    • Item 1
      • Option 1
      • Option 2
    • Item 2
      • Option 3
      • Option 4
  • Navigation Two
  • Navigation Three
  • Group
    • Option 13
    • Option 14
  • Option 1
  • Option 2
  • Option 3
  • Navigation One
    • Option 5
    • Option 6
    • Option 7
    • Option 8
  • Navigation Two
  • Navigation One
  • Navigation Two
    • Option 1
    • Option 2
    • Submenu
      • Option 1
      • Option 2
      • Option 3
    • Submenu 2
  • Navigation Three
  • Navigation One
  • Navigation Two
  • Navigation Three


  • Navigation One
    • Option 1
    • Option 2
    • Option 3
    • Option 4
  • Navigation Two
  • Navigation Three


  • Navigation One
  • Option 5
  • Option 6
Change Mode
Change Style

  • Navigation One
  • Navigation Two
  • Navigation Two
    • Option 3
    • Option 4
    • Submenu
  • Navigation Three
  • Ant Design


  • Navigation One Long Long Long Long
  • Navigation Two
  • O
  • O
Change Mode

  • Navigation One
  • Navigation Two
  • Navigation Two
    • Ant Design, a design language for background applications, is refined by Ant UED Team
    • Option 4
    • Submenu
  • Navigation Three
  • Ant Design
  • Navigation One
  • Navigation Two
  • Navigation Three - Submenu
  • Navigation Four - Link
  • Option 1
  • Option 2
  • Option 3
  • Navigation One
  • Navigation Two
  • Navigation One
  • Navigation Two
  • Navigation Three - Submenu
  • Navigation Four - Link
  • Option 1
  • Option 2
  • Option 3
  • Navigation One
    • Option 5
    • Option 6
    • Option 7
    • Option 8
  • Navigation Two