# 导航菜单

- 页面: https://jiguang132.com/zh/resources/ant-design/docs/menu
- 资源: Ant Design (https://jiguang132.com/zh/resources/ant-design.md)
- 全部指南: https://jiguang132.com/zh/resources/ant-design/docs.md

为页面和功能提供导航的菜单列表。


## 何时使用 {#when-to-use}

导航菜单是一个网站的灵魂，用户依赖导航在各个页面中进行跳转。一般分为顶部导航和侧边导航，顶部导航提供全局性的类目和功能，侧边导航提供多级结构来收纳和排列网站架构。

更多布局和导航的使用可以参考：[通用布局](/components/layout)。

## 开发者注意事项 {#notes-for-developers}

- Menu 元素为 `ul`，因而仅支持 [`li` 以及 `script-supporting` 子元素](https://html.spec.whatwg.org/multipage/grouping-content.html#the-ul-element)。因而你的子节点元素应该都在 `Menu.Item` 内使用。
- Menu 需要计算节点结构，因而其子元素仅支持 `Menu.*` 以及对此进行封装的 HOC 组件。

## 代码演示 {#examples}


- 顶部导航 · `horizontal`

- 内嵌菜单 · `inline`
- 缩起内嵌菜单 · `inline-collapsed`
- 菜单项提示 · `tooltip`
- 只展开当前父级菜单 · `sider-current`
- 垂直菜单 · `vertical`
- 主题 · `theme`
- 子菜单主题 · `submenu-theme`
- 切换菜单类型 · `switch-mode`
- 自定义语义结构的样式和类 · `style-class`





- 自定义弹出框 · `custom-popup-render`


## API

通用属性参考：[通用属性](#jguang-common-props)

### Menu

| 参数 | 说明 | 类型 | 默认值 | 版本 | [全局配置](/components/config-provider#component-config) |
| --- | --- | --- | --- | --- | --- |
| classNames | 用于自定义组件内部各语义化结构的 class，支持对象或函数 | Record<[SemanticDOM](#semantic-dom), string> \| (info: { props }) => Record<[SemanticDOM](#semantic-dom), string> | - |  | 6.0.0 |
| defaultOpenKeys | 初始展开的 SubMenu 菜单项 key 数组 | string\[] | - |  | × |
| defaultSelectedKeys | 初始选中的菜单项 key 数组 | string\[] | - |  | × |
| expandIcon | 自定义展开图标 | ReactNode \| `(props: SubMenuProps & { isSubMenu: boolean }) => ReactNode` | - | 4.9.0 | 5.15.0 |
| forceSubMenuRender | 在子菜单展示之前就渲染进 DOM | boolean | false |  | × |
| inlineCollapsed | inline 时菜单是否收起状态 | boolean | - |  | × |
| inlineIndent | inline 模式的菜单缩进宽度 | number | 24 |  | × |
| items | 菜单内容 | [ItemType\[\]](#itemtype) | - | 4.20.0 | × |
| mode | 菜单类型，现在支持垂直、水平、和内嵌模式三种 | `vertical` \| `horizontal` \| `inline` | `vertical` |  | × |
| multiple | 是否允许多选 | boolean | false |  | × |
| openKeys | 当前展开的 SubMenu 菜单项 key 数组 | string\[] | - |  | × |
| overflowedIndicator | 用于自定义 Menu 水平空间不足时的省略收缩的图标 | ReactNode | `<EllipsisOutlined />` |  | × |
| selectable | 是否允许选中 | boolean | true |  | × |
| selectedKeys | 当前选中的菜单项 key 数组 | string\[] | - |  | × |
| styles | 用于自定义组件内部各语义化结构的行内 style，支持对象或函数 | Record<[SemanticDOM](#semantic-dom) , CSSProperties> \| (info: { props }) => Record<[SemanticDOM](#semantic-dom) , CSSProperties> | - |  | 6.0.0 |
| subMenuCloseDelay | 用户鼠标离开子菜单后关闭延时，单位：秒 | number | 0.1 |  | × |
| subMenuOpenDelay | 用户鼠标进入子菜单后开启延时，单位：秒 | number | 0 |  | × |
| tooltip | 配置 inline 折叠时的 MenuItem 悬浮提示，设为 `false` 可关闭 | false \| TooltipProps | - | 6.3.0 | × |
| theme | 主题颜色 | `light` \| `dark` | `light` |  | × |
| triggerSubMenuAction | SubMenu 展开/关闭的触发行为 | `hover` \| `click` | `hover` |  | × |
| onClick | 点击 MenuItem 调用此函数 | function({ key, keyPath, domEvent, itemData }) | - |  | × |
| onDeselect | 取消选中时调用，仅在 multiple 生效 | function({ key, keyPath, selectedKeys, domEvent, itemData }) | - |  | × |
| onOpenChange | SubMenu 展开/关闭的回调 | function(openKeys: string\[]) | - |  | × |
| onSelect | 被选中时调用 | function({ key, keyPath, selectedKeys, domEvent, itemData }) | - |  | × |
| popupRender | 自定义子菜单的弹出框 | (node: ReactElement, props: { item: SubMenuProps; keys: string[] }) => ReactNode | - |  | × |

> 更多属性查看 [@rc-component/menu](https://github.com/react-component/menu#api)

### ItemType

> type ItemType = [MenuItemType](#menuitemtype) | [SubMenuType](#submenutype) | [MenuItemGroupType](#menuitemgrouptype) | [MenuDividerType](#menudividertype);

#### MenuItemType

| 参数     | 说明                     | 类型      | 默认值 | 版本   |
| -------- | ------------------------ | --------- | ------ | ------ |
| danger   | 展示错误状态样式         | boolean   | false  |        |
| disabled | 是否禁用                 | boolean   | false  |        |
| extra    | 额外节点                 | ReactNode | -      | 5.21.0 |
| icon     | 菜单图标                 | ReactNode | -      |        |
| key      | item 的唯一标志          | string    | -      |        |
| label    | 菜单项标题               | ReactNode | -      |        |
| title    | 设置收缩时展示的悬浮标题 | string    | -      |        |

#### SubMenuType

| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| children | 子菜单的菜单项 | [ItemType\[\]](#itemtype) | - |  |
| disabled | 是否禁用 | boolean | false |  |
| icon | 菜单图标 | ReactNode | - |  |
| key | 唯一标志 | string | - |  |
| label | 菜单项标题 | ReactNode | - |  |
| popupClassName | 子菜单样式，`mode="inline"` 时无效 | string | - |  |
| popupOffset | 子菜单偏移量，`mode="inline"` 时无效 | \[number, number] | - |  |
| theme | 设置子菜单的主题，默认从 Menu 上继承 | `light` \| `dark` | - |  |
| onTitleClick | 点击子菜单标题 | function({ key, domEvent }) | - |  |
| popupRender | 自定义当前子菜单的弹出框 | (node: ReactElement, props: { item: SubMenuProps; keys: string[] }) => ReactNode | - |  |

#### MenuItemGroupType

定义类型为 `group` 时，会作为分组处理:

```ts
const groupItem = {
  type: 'group', // Must have
  label: 'My Group',
  children: [],
};
```

| 参数     | 说明         | 类型                              | 默认值 | 版本 |
| -------- | ------------ | --------------------------------- | ------ | ---- |
| children | 分组的菜单项 | [MenuItemType\[\]](#menuitemtype) | -      |      |
| label    | 分组标题     | ReactNode                         | -      |      |

#### MenuDividerType

菜单项分割线，只用在弹出菜单内，需要定义类型为 `divider`：

```ts
const dividerItem = {
  type: 'divider', // Must have
};
```

| 参数   | 说明     | 类型    | 默认值 | 版本 |
| ------ | -------- | ------- | ------ | ---- |
| dashed | 是否虚线 | boolean | false  |      |

## FAQ

### 为何 Menu 的子元素会渲染两次？ {#faq-render-twice}

Menu 通过[二次渲染](https://github.com/react-component/menu/blob/f4684514096d6b7123339cbe72e7b0f68db0bce2/src/Menu.tsx#L543)收集嵌套结构信息以支持 HOC 的结构。合并成一个推导结构会使得逻辑变得十分复杂，欢迎 PR 以协助改进该设计。

### 在 Flex 布局中，Menu 没有按照预期响应式省略菜单？ {#faq-flex-layout}

Menu 初始化时会先全部渲染，然后根据宽度裁剪内容。当处于 Flex 布局中，你需要告知其预期宽度为响应式宽度（[在线 Demo](https://codesandbox.io/s/ding-bu-dao-hang-antd-4-21-7-forked-5e3imy?file=/demo.js)）：

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

## Semantic DOM

| 语义节点 | 原生说明 | 版本 |
| --- | --- | --- |
| `root` | 根元素，包含菜单容器的基础样式和布局 | — |
| `item` | 条目元素，包含相对定位、块级显示、外边距、空白符处理、光标样式、过渡动画等菜单项的基础交互样式 | — |
| `itemIcon` | 图标元素，包含最小宽度、字体大小、过渡动画、图标重置样式，以及与文本的间距控制 | — |
| `itemContent` | 条目内容元素，包含菜单项内容的布局和排版样式 | — |
| `subMenu.itemTitle` | 子菜单标题元素，包含子菜单标题的样式和交互效果 | — |
| `subMenu.list` | 子菜单列表元素，包含子菜单列表的布局和容器样式 | — |
| `subMenu.item` | 子菜单单项元素，包含子菜单项的样式和交互效果 | — |
| `subMenu.itemIcon` | 子菜单条目图标元素，包含子菜单图标的尺寸和样式 | — |
| `subMenu.itemContent` | 子菜单条目内容元素，包含子菜单内容的布局和排版 | — |
| `itemTitle` | 菜单标题元素(horizontal 模式不生效)，包含标题文字的样式和布局 | — |
| `list` | 菜单列表元素(horizontal 模式不生效)，包含菜单列表的布局和容器样式 | — |
| `popup` | 弹出菜单(inline 模式不生效)，包含弹出层的定位、层级、背景等样式 | — |

语义说明来源: `vendor/components/menu/demo/_semantic.tsx`

## 主题变量（Design Token）{#design-token}

类型、继承关系和原生令牌声明保持固定源码原文；默认值由原生主题计算，并可能受 ConfigProvider 覆盖。本表不伪造静态默认值。

| 令牌 | 类型 | 原生说明 |
| --- | --- | --- |
| `dropdownWidth` | `number \| string` | 弹出菜单的宽度 |
| `zIndexPopup` | `number` | 弹出菜单的 z-index |
| `colorGroupTitle` | `string` | 见原生声明及继承类型 |
| `groupTitleColor` | `string` | 分组标题文字颜色 |
| `groupTitleLineHeight` | `string \| number` | 分组标题文字高度 |
| `groupTitleFontSize` | `number` | 分组标题文字大小 |
| `radiusItem` | `number` | 见原生声明及继承类型 |
| `itemBorderRadius` | `number` | 菜单项的圆角 |
| `radiusSubMenuItem` | `number` | 见原生声明及继承类型 |
| `subMenuItemBorderRadius` | `number` | 子菜单项的圆角 |
| `colorItemText` | `string` | 见原生声明及继承类型 |
| `itemColor` | `string` | 菜单项文字颜色 |
| `colorItemTextHover` | `string` | 见原生声明及继承类型 |
| `itemHoverColor` | `string` | 菜单项文字悬浮颜色 |
| `colorItemTextHoverHorizontal` | `string` | 见原生声明及继承类型 |
| `horizontalItemHoverColor` | `string` | 水平菜单项文字悬浮颜色 |
| `colorItemTextSelected` | `string` | 见原生声明及继承类型 |
| `itemSelectedColor` | `string` | 菜单项文字选中颜色 |
| `subMenuItemSelectedColor` | `string` | 子菜单内有选中项时，子菜单标题色 |
| `colorItemTextSelectedHorizontal` | `string` | 见原生声明及继承类型 |
| `horizontalItemSelectedColor` | `string` | 水平菜单项文字选中颜色 |
| `colorItemTextDisabled` | `string` | 见原生声明及继承类型 |
| `itemDisabledColor` | `string` | 菜单项文字禁用颜色 |
| `colorDangerItemText` | `string` | 见原生声明及继承类型 |
| `dangerItemColor` | `string` | 危险菜单项文字颜色 |
| `colorDangerItemTextHover` | `string` | 见原生声明及继承类型 |
| `dangerItemHoverColor` | `string` | 危险菜单项文字悬浮颜色 |
| `colorDangerItemTextSelected` | `string` | 见原生声明及继承类型 |
| `dangerItemSelectedColor` | `string` | 危险菜单项文字选中颜色 |
| `colorDangerItemBgActive` | `string` | 见原生声明及继承类型 |
| `dangerItemActiveBg` | `string` | 危险菜单项激活态背景色 |
| `colorDangerItemBgSelected` | `string` | 见原生声明及继承类型 |
| `dangerItemSelectedBg` | `string` | 危险菜单项选中背景色 |
| `colorItemBg` | `string` | 见原生声明及继承类型 |
| `itemBg` | `string` | 菜单项背景色 |
| `colorItemBgHover` | `string` | 见原生声明及继承类型 |
| `itemHoverBg` | `string` | 菜单项悬浮态背景色 |
| `colorSubItemBg` | `string` | 见原生声明及继承类型 |
| `subMenuItemBg` | `string` | 子菜单项背景色 |
| `colorItemBgActive` | `string` | 见原生声明及继承类型 |
| `itemActiveBg` | `string` | 菜单项激活态背景色 |
| `colorItemBgSelected` | `string` | 见原生声明及继承类型 |
| `itemSelectedBg` | `string` | 菜单项选中态背景色 |
| `colorItemBgSelectedHorizontal` | `string` | 见原生声明及继承类型 |
| `horizontalItemSelectedBg` | `string` | 水平菜单项选中态背景色 |
| `colorActiveBarWidth` | `number \| string` | 见原生声明及继承类型 |
| `activeBarWidth` | `number \| string` | 菜单项指示条宽度 |
| `colorActiveBarHeight` | `number` | 见原生声明及继承类型 |
| `activeBarHeight` | `number` | 菜单项指示条高度 |
| `colorActiveBarBorderSize` | `number` | 见原生声明及继承类型 |
| `activeBarBorderWidth` | `number \| string` | 菜单项指示条边框宽度 |
| `itemMarginInline` | `number` | 菜单项横向外间距 |
| `horizontalItemHoverBg` | `string` | 横向菜单项横悬浮态背景色 |
| `horizontalItemBorderRadius` | `number` | 横向菜单项圆角 |
| `itemHeight` | `number \| string` | 菜单项高度 |
| `collapsedWidth` | `number \| string` | 收起后的宽度 |
| `popupBg` | `string` | 弹出框背景色 |
| `itemMarginBlock` | `CSSProperties['marginBlock']` | 菜单项纵向外间距 |
| `itemPaddingInline` | `CSSProperties['paddingInline']` | 菜单项横向内间距 |
| `horizontalLineHeight` | `CSSProperties['lineHeight']` | 横向菜单行高 |
| `iconMarginInlineEnd` | `CSSProperties['marginInlineEnd']` | 图标与文字间距 |
| `iconSize` | `number` | 图标尺寸 |
| `collapsedIconSize` | `number` | 收起时图标尺寸 |
| `darkPopupBg` | `string` | 暗色模式下的浮层菜单的背景颜色 |
| `darkItemColor` | `string` | 暗色模式下的菜单项文字颜色 |
| `darkDangerItemColor` | `string` | 暗色模式下的危险菜单项文字颜色 |
| `darkItemBg` | `string` | 暗色模式下的菜单项背景 |
| `darkSubMenuItemBg` | `string` | 暗色模式下的子菜单项背景 |
| `darkItemSelectedColor` | `string` | 暗色模式下的菜单项选中颜色 |
| `darkItemSelectedBg` | `string` | 暗色模式下的菜单项选中背景 |
| `darkItemHoverBg` | `string` | 暗色模式下的菜单项悬浮背景 |
| `darkGroupTitleColor` | `string` | 暗色模式下的分组标题文字颜色 |
| `darkItemHoverColor` | `string` | 暗色模式下的菜单项悬浮颜色 |
| `darkItemDisabledColor` | `string` | 暗色模式下的菜单项禁用颜色 |
| `darkDangerItemSelectedBg` | `string` | 暗色模式下的危险菜单项选中背景 |
| `darkDangerItemHoverColor` | `string` | 暗色模式下的危险菜单项悬浮文字背景 |
| `darkDangerItemSelectedColor` | `string` | 暗色模式下的危险菜单项选中文字颜色 |
| `darkDangerItemActiveBg` | `string` | 暗色模式下的危险菜单项激活态背景 |
| `itemWidth` | `number \| string` | 见原生声明及继承类型 |

声明来源: `vendor/components/menu/style/index.ts`

```ts
import type { CSSProperties } from 'react';

import type { CSSObject } from '@ant-design/cssinjs';

import { unit } from '@ant-design/cssinjs';

import { FastColor } from '@ant-design/fast-color';

import type { CssUtil } from 'antd-style';

import { clearFix, resetComponent, resetIcon, textEllipsis } from '../../style';

import { genCollapseMotion, initSlideMotion, initZoomMotion } from '../../style/motion';

import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks, mergeToken } from '../../theme/internal';

import getHorizontalStyle from './horizontal';

import getRTLStyle from './rtl';

import getThemeStyle from './theme';

import getVerticalStyle from './vertical';

/** Component only token. Which will handle additional calculation of alias token */
export interface ComponentToken {
  /**
   * @desc 弹出菜单的宽度
   * @descEN Width of popup menu
   */
  dropdownWidth: number | string;
  /**
   * @desc 弹出菜单的 z-index
   * @descEN z-index of popup menu
   */
  zIndexPopup: number;

  // Group
  /** @deprecated Use `groupTitleColor` instead */
  colorGroupTitle: string;
  /**
   * @desc 分组标题文字颜色
   * @descEN Color of group title text
   */
  groupTitleColor: string;
  /**
   * @desc 分组标题文字高度
   * @descEN line-height of group title
   */
  groupTitleLineHeight: string | number;
  /**
   * @desc 分组标题文字大小
   * @descEN font-size of group title
   */
  groupTitleFontSize: number;

  // radius
  /** @deprecated Use `itemBorderRadius` instead */
  radiusItem: number;
  /**
   * @desc 菜单项的圆角
   * @descEN Radius of menu item
   */
  itemBorderRadius: number;

  /** @deprecated Use `subMenuItemBorderRadius` instead */
  radiusSubMenuItem: number;
  /**
   * @desc 子菜单项的圆角
   * @descEN Radius of sub-menu item
   */
  subMenuItemBorderRadius: number;

  // Item Text
  // > Default
  /** @deprecated Use `itemColor` instead */
  colorItemText: string;
  /**
   * @desc 菜单项文字颜色
   * @descEN Color of menu item text
   */
  itemColor: string;

  /** @deprecated Use `itemHoverColor` instead */
  colorItemTextHover: string;
  /**
   * @desc 菜单项文字悬浮颜色
   * @descEN Hover color of menu item text
   */
  itemHoverColor: string;

  /** @deprecated Use `horizontalItemHoverColor` instead */
  colorItemTextHoverHorizontal: string;
  /**
   * @desc 水平菜单项文字悬浮颜色
   * @descEN Hover color of horizontal menu item text
   */
  horizontalItemHoverColor: string;

  /** @deprecated Use `itemSelectedColor` instead */
  colorItemTextSelected: string;
  /**
   * @desc 菜单项文字选中颜色
   * @descEN Color of selected menu item text
   */
  itemSelectedColor: string;
  /**
   * @desc 子菜单内有选中项时，子菜单标题色
   * @descEN Color of submenu title when submenu has selected item
   */
  subMenuItemSelectedColor: string;

  /** @deprecated Use `horizontalItemSelectedColor` instead */
  colorItemTextSelectedHorizontal: string;
  /**
   * @desc 水平菜单项文字选中颜色
   * @descEN Color of selected horizontal menu item text
   */
  horizontalItemSelectedColor: string;

  // > Disabled
  /** @deprecated Use `itemDisabledColor` instead */
  colorItemTextDisabled: string;
  /**
   * @desc 菜单项文字禁用颜色
   * @descEN Color of disabled menu item text
   */
  itemDisabledColor: string;

  // > Danger
  /** @deprecated Use `dangerItemColor` instead */
  colorDangerItemText: string;
  /**
   * @desc 危险菜单项文字颜色
   * @descEN Color of danger menu item text
   */
  dangerItemColor: string;

  /** @deprecated Use `dangerItemHoverColor` instead */
  colorDangerItemTextHover: string;
  /**
   * @desc 危险菜单项文字悬浮颜色
   * @descEN Hover color of danger menu item text
   */
  dangerItemHoverColor: string;

  /** @deprecated Use `dangerItemSelectedColor` instead */
  colorDangerItemTextSelected: string;
  /**
   * @desc 危险菜单项文字选中颜色
   * @descEN Color of selected danger menu item text
   */
  dangerItemSelectedColor: string;

  /** @deprecated Use `dangerItemActiveBg` instead */
  colorDangerItemBgActive: string;
  /**
   * @desc 危险菜单项激活态背景色
   * @descEN Background color of danger menu item when active
   */
  dangerItemActiveBg: string;

  /** @deprecated Use `dangerItemSelectedBg` instead */
  colorDangerItemBgSelected: string;
  /**
   * @desc 危险菜单项选中背景色
   * @descEN Background color of selected danger menu item
   */
  dangerItemSelectedBg: string;

  // Item Bg
  /** @deprecated Use `itemBg` instead */
  colorItemBg: string;
  /**
   * @desc 菜单项背景色
   */
  itemBg: string;

  /** @deprecated Use `itemHoverBg` instead */
  colorItemBgHover: string;
  /**
   * @desc 菜单项悬浮态背景色
   * @descEN Background color of menu item when hover
   */
  itemHoverBg: string;

  /** @deprecated Use `subMenuItemBg` instead */
  colorSubItemBg: string;
  /**
   * @desc 子菜单项背景色
   * @descEN Background color of sub-menu item
   */
  subMenuItemBg: string;

  // > Default
  /** @deprecated Use `itemActiveBg` instead */
  colorItemBgActive: string;
  /**
   * @desc 菜单项激活态背景色
   * @descEN Background color of menu item when active
   */
  itemActiveBg: string;

  /** @deprecated Use `itemSelectedBg` instead */
  colorItemBgSelected: string;
  /**
   * @desc 菜单项选中态背景色
   * @descEN Background color of menu item when selected
   */
  itemSelectedBg: string;

  /** @deprecated Use `horizontalItemSelectedBg` instead */
  colorItemBgSelectedHorizontal: string;
  /**
   * @desc 水平菜单项选中态背景色
   * @descEN Background color of horizontal menu item when selected
   */
  horizontalItemSelectedBg: string;

  // Ink Bar
  /** @deprecated Use `activeBarWidth` instead */
  colorActiveBarWidth: number | string;
  /**
   * @desc 菜单项指示条宽度
   * @descEN Width of menu item active bar
   */
  activeBarWidth: number | string;

  /** @deprecated Use `activeBarHeight` instead */
  colorActiveBarHeight: number;
  /**
   * @desc 菜单项指示条高度
   * @descEN Height of menu item active bar
   */
  activeBarHeight: number;

  /** @deprecated Use `activeBarBorderWidth` instead */
  colorActiveBarBorderSize: number;
  /**
   * @desc 菜单项指示条边框宽度
   * @descEN Border width of menu item active bar
   */
  activeBarBorderWidth: number | string;

  /**
   * @desc 菜单项横向外间距
   * @descEN Horizontal margin of menu item
   */
  itemMarginInline: number;
  /**
   * @desc 横向菜单项横悬浮态背景色
   * @descEN Background color of horizontal menu item when hover
   */
  horizontalItemHoverBg: string;
  /**
   * @desc 横向菜单项圆角
   * @descEN Border radius of horizontal menu item
   */
  horizontalItemBorderRadius: number;
  /**
   * @desc 菜单项高度
   * @descEN Height of menu item
   */
  itemHeight: number | string;
  /**
   * @desc 收起后的宽度
   * @descEN Width when collapsed
   */
  collapsedWidth: number | string;
  /**
   * @desc 弹出框背景色
   * @descEN Background color of popup
   */
  popupBg: string;
  /**
   * @desc 菜单项纵向外间距
   * @descEN margin-block of menu item
   */
  itemMarginBlock: CSSProperties['marginBlock'];
  /**
   * @desc 菜单项横向内间距
   * @descEN padding-inline of menu item
   */
  itemPaddingInline: CSSProperties['paddingInline'];
  /**
   * @desc 横向菜单行高
   * @descEN LineHeight of horizontal menu item
   */
  horizontalLineHeight: CSSProperties['lineHeight'];
  /**
   * @desc 图标与文字间距
   * @descEN Spacing between icon and text
   */
  iconMarginInlineEnd: CSSProperties['marginInlineEnd'];
  /**
   * @desc 图标尺寸
   * @descEN Size of icon
   */
  iconSize: number;
  /**
   * @desc 收起时图标尺寸
   * @descEN Size of icon when collapsed
   */
  collapsedIconSize: number;

  // Dark
  /**
   * @desc 暗色模式下的浮层菜单的背景颜色
   * @descEN The background color of the overlay menu in dark mode.
   */
  darkPopupBg: string;
  /**
   * @desc 暗色模式下的菜单项文字颜色
   * @descEN Color of menu item text in dark mode
   */
  darkItemColor: string;
  /**
   * @desc 暗色模式下的危险菜单项文字颜色
   * @descEN Color of danger menu item text in dark mode
   */
  darkDangerItemColor: string;
  /**
   * @desc 暗色模式下的菜单项背景
   * @descEN Background of menu item in dark mode
   */
  darkItemBg: string;
  /**
   * @desc 暗色模式下的子菜单项背景
   * @descEN Background of submenu item in dark mode
   */
  darkSubMenuItemBg: string;
  /**
   * @desc 暗色模式下的菜单项选中颜色
   * @descEN Color of selected menu item in dark mode
   */
  darkItemSelectedColor: string;
  /**
   * @desc 暗色模式下的菜单项选中背景
   * @descEN Background of active menu item in dark mode
   */
  darkItemSelectedBg: string;
  /**
   * @desc 暗色模式下的菜单项悬浮背景
   * @descEN Background of hovered menu item in dark mode
   */
  darkItemHoverBg: string;
  /**
   * @desc 暗色模式下的分组标题文字颜色
   * @descEN Color of group title text in dark mode
   */
  darkGroupTitleColor: string;
  /**
   * @desc 暗色模式下的菜单项悬浮颜色
   * @descEN Color of hovered menu item in dark mode
   */
  darkItemHoverColor: string;
  /**
   * @desc 暗色模式下的菜单项禁用颜色
   * @descEN Color of disabled menu item in dark mode
   */
  darkItemDisabledColor: string;
  /**
   * @desc 暗色模式下的危险菜单项选中背景
   * @descEN Background of active danger menu item in dark mode
   */
  darkDangerItemSelectedBg: string;
  /**
   * @desc 暗色模式下的危险菜单项悬浮文字背景
   * @descEN Background of hovered danger menu item in dark mode
   */
  darkDangerItemHoverColor: string;
  /**
   * @desc 暗色模式下的危险菜单项选中文字颜色
   * @descEN Color of selected danger menu item in dark mode
   */
  darkDangerItemSelectedColor: string;
  /**
   * @desc 暗色模式下的危险菜单项激活态背景
   * @descEN Background of active danger menu item in dark mode
   */
  darkDangerItemActiveBg: string;
  /** @internal */
  itemWidth: number | string;
}

/**
 * @desc Menu 组件的 Token
 * @descEN Token for Menu component
 */
export interface MenuToken extends FullToken<'Menu'> {
  /**
   * @desc 水平菜单高度
   * @descEN Height of horizontal menu
   */
  menuHorizontalHeight: number | string;
  /**
   * @desc 菜单箭头尺寸
   * @descEN Size of menu arrow
   */
  menuArrowSize: number | string;
  /**
   * @desc 菜单箭头偏移量
   * @descEN Offset of menu arrow
   */
  menuArrowOffset: number | string;
  /**
   * @desc 子菜单背景色
   * @descEN Background color of sub-menu
   */
  menuSubMenuBg: string;
  /**
   * @desc 暗色模式下的浮层菜单背景色
   * @descEN Background color of popup menu in dark mode
   */
  darkPopupBg: string;
}
```


## 原生通用属性 {#jguang-common-props}


> Tips: 以下通用属性适用于 antd 大部分组件，不支持的组件会单独说明。

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| style | 自定义样式 | CSSProperties | - |
| className | 自定义类名 | string | - |
| rootClassName | 添加在组件最外层的 className | string | - |
| autoFocus | 自动获取焦点，仅对表单类、链接、交互容器等可聚焦元素生效 | boolean | false |


## 安装并复现示例

```bash
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23
```

使用 ConfigProvider 和原生 App，并单独配置 dayjs 语言。每个示例在查看代码中列出完整源码文件和额外固定依赖。示例名称用于选择演示，不是组件通用属性。主题、语言与 SSR 初始化见资源安装指南。

## 原生类型参考

源码查看器包含未修改的原生实现和以下声明文件，继承类型仍位于原生包中。代码中的英文注释保留为源码参考。

- `vendor/components/menu/MenuContext.tsx`
- `vendor/components/menu/MenuDivider.tsx`
- `vendor/components/menu/MenuItem.tsx`
- `vendor/components/menu/OverrideContext.tsx`
- `vendor/components/menu/SubMenu.tsx`
- `vendor/components/menu/index.tsx`
- `vendor/components/menu/interface.ts`
- `vendor/components/menu/menu.tsx`
- `vendor/components/menu/style/index.ts`

## 来源与许可

https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd

保留原生中英文正文与可执行示例；官网专用的嵌入章节和令牌表格在本地展开。Ant Design 使用 MIT 许可，另列依赖的许可证也需保留。上传预览禁止向外发起请求，不提供后端服务。

---

JGuang 全部资源索引: https://jiguang132.com/llms.txt
