TopMenu.md
2.63 KB
Top Navigation
Horizontal top navigation menu.
- Edit Online :
https://codesandbox.io/s/x39wvqoyzq
import React, { Component, Fragment } from 'react'
import { Menu, Icon } from 'antd'
const SubMenu = Menu.SubMenu
const MenuItemGroup = Menu.ItemGroup
export default class TopMenu extends Component {
state = {
current: 'mail'
}
handleClick = e => {
console.log('click ', e)
this.setState({
current: e.key
})
}
render() {
return (
<Menu
onClick={this.handleClick}
selectedKeys={[this.state.current]}
mode="horizontal"
>
<Menu.Item key="mail">
<Icon type="mail" />
Navigation One
</Menu.Item>
<Menu.Item key="app" disabled>
<Icon type="appstore" />
Navigation Two
</Menu.Item>
<SubMenu
title={
<span className="submenu-title-wrapper">
<Icon type="setting" />
Navigation Three - Submenu
</span>
}
>
<MenuItemGroup title="Item 1">
<Menu.Item key="setting:1">Option 1</Menu.Item>
<Menu.Item key="setting:2">Option 2</Menu.Item>
</MenuItemGroup>
<MenuItemGroup title="Item 2">
<Menu.Item key="setting:3">Option 3</Menu.Item>
<Menu.Item key="setting:4">Option 4</Menu.Item>
</MenuItemGroup>
</SubMenu>
<Menu.Item key="alipay">
<a
href="https://ant.design"
target="_blank"
rel="noopener noreferrer"
>
Navigation Four - Link
</a>
</Menu.Item>
</Menu>
)
}
}
Menu
| Property | Description | Type | Deault |
|---|---|---|---|
| mode | type of the menu; vertical, horizontal, and inline modes are supported |
string: vertical \ |
horizontal \ |
| theme | color theme of the menu | string: light dark
|
light |
| onClick | callback executed when a menu item is clicked | function({ item, key, keyPath }) | - |
| selectedKeys | array with the keys of currently selected menu items | string[] |