Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

React Menu

License

NotificationsYou must be signed in to change notification settings

react-component/menu

Repository files navigation


React Menu Component. port fromhttps://github.com/kissyteam/menu

NPM versionnpm downloadbuild statusCodecovbundle sizedumi

Install

rc-menu

Usage

importMenu,{SubMenu,MenuItem}from'rc-menu';ReactDOM.render(<Menu><MenuItem>1</MenuItem><SubMenutitle="2"><MenuItem>2-1</MenuItem></SubMenu></Menu>,container,);

Compatibility

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versions

API

Menu props

nametypedefaultdescription
refReact.HTMLLIElementget dom node
classNameStringadditional css class of root dom node
modeStringverticalone of ["horizontal","inline","vertical-left","vertical-right"]
activeKeyStringinitial and current active menu item's key.
defaultActiveFirstBooleanfalsewhether active first menu item when show if activeKey is not set or invalid
multipleBooleanfalsewhether allow multiple select
selectableBooleantrueallow selecting menu items
selectedKeysString[][]selected keys of items
defaultSelectedKeysString[][]initial selected keys of items
openKeysString[][]open keys of SubMenuItem
defaultOpenKeysString[][]initial open keys of SubMenuItem
onSelectfunction({key:String, item:ReactComponent, domEvent:Event, selectedKeys:String[]})called when select a menu item
onClickfunction({key:String, item:ReactComponent, domEvent:Event, keyPath: String[]})called when click a menu item
onOpenChange(openKeys:String[]) => voidcalled when open/close sub menu
onDeselectfunction({key:String, item:ReactComponent, domEvent:Event, selectedKeys:String[]})called when deselect a menu item. only called when allow multiple
triggerSubMenuActionEnum { hover, click }hoverwhich action can trigger submenu open/close
openAnimation{enter:function,leave:function}|Stringanimate when sub menu open or close. see @rc-component/motion for object type.
openTransitionStringcss transitionName when sub menu open or close
subMenuOpenDelayNumber0delay time to show popup sub menu. unit: s
subMenuCloseDelayNumber0.1delay time to hide popup sub menu. unit: s
forceSubMenuRenderBooleanfalsewhether to render submenu even if it is not visible
getPopupContainerFunction(menuDOMNode): HTMLElement() => document.bodyWhere to render the DOM node of popup menu when the mode is horizontal or vertical
builtinPlacementsObject of alignConfigs fordom-alignseeplacements.tsDescribes how the popup menus should be positioned
itemIconReactNode | (props: MenuItemProps) => ReactNodeSpecify the menu item icon.
expandIconReactNode | (props: SubMenuProps & { isSubMenu: boolean }) => ReactNodeSpecify the menu item icon.
directionStringLayout direction of menu component, it supports RTL direction too.
inlineIndentNumber24Padding level multiplier. Right or left padding depends on param "direction".

Menu.Item props

nametypedefaultdescription
classNameStringadditional css class of root dom node
disabledBooleanfalseno effect for click or keydown for this item
extraReact.ReactNodeSpecify menu item extra node.
keyObjectcorresponding to activeKey
onMouseEnterFunction({eventKey, domEvent})
onMouseLeaveFunction({eventKey, domEvent})
itemIconReactNode | (props: MenuItemProps) => ReactNodeSpecify the menu item icon.

Menu.SubMenu props

nametypedefaultdescription
refReact.HTMLLIElementget dom node
popupClassNameStringadditional css class of root dom node
popupStyleCSSPropertiesadditional css style of root dom node
titleString/ReactElementsub menu's content
overflowedIndicatorString/ReactElement···overflow indicator when menu overlows in horizontal mode
keyObjectcorresponding to activeKey
disabledBooleanfalseno effect for click or keydown for this item
onMouseEnterFunction({eventKey, domEvent})
onMouseLeaveFunction({eventKey, domEvent})
onTitleMouseEnterFunction({eventKey, domEvent})
onTitleMouseLeaveFunction({eventKey, domEvent})
onTitleClickFunction({eventKey, domEvent})
popupOffsetArrayThe offset of the popup submenu, in an x, y coordinate array. e.g.: `[0,15]`
expandIconReactNode | (props: SubMenuProps) => ReactNodeSpecify the menu item icon.
itemIconReactNode | (props: SubMenuProps & { isSubMenu: boolean }) => ReactNodeSpecify the menu item icon.

Menu.Divider props

none

Menu.ItemGroup props

nametypedefaultdescription
refReact.HTMLLIElementget dom node
titleString|React.Elementtitle of item group
childrenReact.Element[]MenuItems belonged to this group

Development

npm installnpm start

Example

http://localhost:8001/examples/index.md

online example:http://react-component.github.io/menu/examples/

Test Case

npm testnpm run chrome-test

Coverage

npm run coverage

open coverage/ dir

License

rc-menu is released under the MIT license.


[8]ページ先頭

©2009-2025 Movatter.jp