# rc-menu --- react menu component. port from https://github.com/kissyteam/menu [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![gemnasium deps][gemnasium-image]][gemnasium-url] [![node version][node-image]][node-url] [![npm download][download-image]][download-url] [npm-image]: http://img.shields.io/npm/v/rc-menu.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-menu [travis-image]: https://img.shields.io/travis/react-component/menu.svg?style=flat-square [travis-url]: https://travis-ci.org/react-component/menu [coveralls-image]: https://img.shields.io/coveralls/react-component/menu.svg?style=flat-square [coveralls-url]: https://coveralls.io/r/react-component/menu?branch=master [gemnasium-image]: http://img.shields.io/gemnasium/react-component/menu.svg?style=flat-square [gemnasium-url]: https://gemnasium.com/react-component/menu [node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square [node-url]: http://nodejs.org/download/ [download-image]: https://img.shields.io/npm/dm/rc-menu.svg?style=flat-square [download-url]: https://npmjs.org/package/rc-menu ## Screenshot  ## Usage ```jsx import Menu, {SubMenu, MenuItem} from 'rc-menu'; ReactDOM.render(
, container); ``` ## install [](https://npmjs.org/package/rc-menu) ## API ### Menu propsname | type | default | description |
---|---|---|---|
className | String | additional css class of root dom node | |
mode | String | vertical | one of ["horizontal","inline","vertical-left","vertical-right"] |
activeKey | Object | initial and current active menu item's key. | |
defaultActiveFirst | Boolean | false | whether active first menu item when show if activeKey is not set or invalid |
multiple | Boolean | false | whether allow multiple select |
selectable | Boolean | true | allow selecting menu items |
selectedKeys | String[] | [] | selected keys of items |
defaultSelectedKeys | String[] | [] | initial selected keys of items |
openKeys | String[] | [] | open keys of SubMenuItem |
defaultOpenKeys | String[] | [] | initial open keys of SubMenuItem |
onSelect | function({key:String, item:ReactComponent, domEvent:Event, selectedKeys:String[]}) | called when select a menu item | |
onClick | function({key:String, item:ReactComponent, domEvent:Event, keyPath: String[]}) | called when click a menu item | |
onOpenChange | (openKeys:String[]) => void | called when open/close sub menu | |
onDeselect | function({key:String, item:ReactComponent, domEvent:Event, selectedKeys:String[]}) | called when deselect a menu item. only called when allow multiple | |
triggerSubMenuAction | Enum { hover, click } | hover | which action can trigger submenu open/close |
openAnimation | {enter:function,leave:function}|String | animate when sub menu open or close. see rc-animate for object type. | |
openTransition | String | css transitionName when sub menu open or close | |
subMenuOpenDelay | Number | 0 | delay time to show popup sub menu. unit: s |
subMenuCloseDelay | Number | 0.1 | delay time to hide popup sub menu. unit: s |
forceSubMenuRender | Boolean | false | whether to render submenu even if it is not visible |
getPopupContainer | Function(menuDOMNode): HTMLElement | () => document.body | Where to render the DOM node of popup menu when the mode is horizontal or vertical |
builtinPlacements | Object of alignConfigs for dom-align | see placements.jsx | Describes how the popup menus should be positioned |
itemIcon | ReactNode | (props: MenuItemProps) => ReactNode | Specify the menu item icon. | |
expandIcon | ReactNode | (props: SubMenuProps & { isSubMenu: boolean }) => ReactNode | Specify the menu item icon. |
name | type | default | description |
---|---|---|---|
className | String | additional css class of root dom node | |
disabled | Boolean | false | no effect for click or keydown for this item |
key | Object | corresponding to activeKey | |
onMouseEnter | Function({eventKey, domEvent}) | ||
onMouseLeave | Function({eventKey, domEvent}) | ||
itemIcon | ReactNode | (props: MenuItemProps) => ReactNode | Specify the menu item icon. |
name | type | default | description |
---|---|---|---|
popupClassName | String | additional css class of root dom node | |
title | String/ReactElement | sub menu's content | |
overflowedIndicator | String/ReactElement | ยทยทยท | overflow indicator when menu overlows in horizontal mode |
key | Object | corresponding to activeKey | |
disabled | Boolean | false | no effect for click or keydown for this item |
onMouseEnter | Function({eventKey, domEvent}) | ||
onMouseLeave | Function({eventKey, domEvent}) | ||
onTitleMouseEnter | Function({eventKey, domEvent}) | ||
onTitleMouseLeave | Function({eventKey, domEvent}) | ||
onTitleClick | Function({eventKey, domEvent}) | ||
popupOffset | Array | The offset of the popup submenu, in an x, y coordinate array. e.g.: `[0,15]` | |
expandIcon | ReactNode | (props: SubMenuProps) => ReactNode | Specify the menu item icon. | |
itemIcon | ReactNode | (props: SubMenuProps & { isSubMenu: boolean }) => ReactNode | Specify the menu item icon. |
name | type | default | description |
---|---|---|---|
title | String|React.Element | title of item group | |
children | React.Element[] | MenuItems belonged to this group |