A ready-to-use menu component for React
react-metismenu is under development now, It is time to contribute 😊
npm install react-metismenu
In your project you may use --save
or --save-dev
options of npm
With Ecma Script 6 and React Loaders
import React from 'react'
import ReactDOM from 'react-dom'
import MetisMenu from 'react-metismenu'
ReactDOM.render(<MetisMenu />,document.getElementById('dom_id'));
Without Loaders (ES5)
var React = require('react');
var ReactDOM = require('react-dom');
var MetisMenu = require('react-metismenu');
ReactDOM.render(
React.createElement(MetisMenu),
document.getElementById('dom_id')
);
Also you have to embed core css file to your html for MetisMenu to work.
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/alpertuna/react-metismenu/master/dist/react-metismenu.min.css" />
You can find this css in your node_modules/react-metismenu/dist
to embed locally.
MetisMenu (React component) properties
iconClassPrefix
{string} - Prefix for all icon's style class (Defaultfa fa-
)iconLevelDown
{string} - Icon class name for state of collapsed sub menus (Defaultcaret-left
)iconLevelUp
{string} - Icon class name for state of opened sub menus (Default:caret-down
)content
{Object[]} - It keeps all recursive structure of Metismenu
Properties for each item in content
icon
{string} - Icon class name of itemlabel
{string} - Label of itemhref
{string} - Link of item (if item has submenu, href property will be ignored)content
{Object[]} - Submenu of item
import React from 'react'
import ReactDOM from 'react-dom'
import MetisMenu from 'react-metismenu'
var content=[
{
icon: 'icon-class-name',
label: 'Label of Item',
href: '#a-link'
},
{
icon: 'icon-class-name',
label: 'Second Item',
content: [
{
icon: 'icon-class-name',
label: 'Sub Menu of Second Item',
href: '#another-link'
}
]
},
];
ReactDOM.render(<MetisMenu content={content} />, document.getElementById('root'));