Giter VIP home page Giter VIP logo

menu's Introduction

rc-menu


react menu component. port from https://github.com/kissyteam/menu

NPM version build status Test coverage gemnasium deps node version npm download

Screenshot

alt

Usage

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

install

rc-menu

API

Menu props

name 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.

Menu.Item props

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.

Menu.SubMenu props

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.

Menu.Divider props

none

Menu.ItemGroup props

name type default description
title String|React.Element title of item group
children React.Element[] MenuItems belonged to this group

Development

npm install
npm start

Example

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

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

Test Case

npm test
npm run chrome-test

Coverage

npm run coverage

open coverage/ dir

License

rc-menu is released under the MIT license.

menu's People

Contributors

afc163 avatar andreysaleba avatar benjycui avatar blog-lyn avatar cdeutsch avatar ddcat1115 avatar dependabot-support avatar eskimoblood avatar goodoldneon avatar gravitywp avatar jljsj33 avatar jwmann avatar kennethtruong avatar ldabiralai avatar mdedetrich avatar micate avatar nuintun avatar paranoidjk avatar picodoth avatar s0 avatar superraytin avatar theel0ja avatar vincentbel avatar warmhug avatar wasutz avatar williamkhshea avatar yesmeck avatar yiminghe avatar zombiej avatar ztplz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.