# Menu

You can add the component on any page in the template. You need to follow the steps given below:&#x20;

**Step 1:** You need to create a state and functions to handle it's events. Also you need to add the code of menu in the page where you want to add the component. Please check the code snippet given below, we have added the menu in the Ecommerce Dashboard:

```
/**
 * Ecommerce Dashboard
 */

import React, { Component } from 'react'
...

export default class EcommerceDashboard extends Component {
    // Menu State
	state = {
      anchorEl: null,
      selectedIndex: 1,
   };
      
   // Menu Functions
   handleClickListItem = event => {
      this.setState({ anchorEl: event.currentTarget });
   };
   handleMenuItemClick = (event, index) => {
      this.setState({ selectedIndex: index, anchorEl: null });
   };
   handleClose = () => {
      this.setState({ anchorEl: null });
   };
   handleClick = event => {
      this.setState({ anchorEl: event.currentTarget });
   };
	render() {
	   ...
		const { anchorEl } = this.state;
		return (
         ...
                        // Menu Code
						<div>
							<Button variant="contained" color="primary" className="text-white" aria-owns={anchorEl ? 'simple-menu' : null} aria-haspopup="true" onClick={this.handleClick} >
								Open Menu
							</Button>
							<Menu id="simple-menu" anchorEl={anchorEl} open={Boolean(anchorEl)} onClose={this.handleClose} >
								<MenuItem onClick={this.handleClose}>Profile</MenuItem>
								<MenuItem onClick={this.handleClose}>My account</MenuItem>
								<MenuItem onClick={this.handleClose}>Logout</MenuItem>
							</Menu>
						</div>
				...
```

**Step 2:** Now Import the component from its parent library.

```
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import Button from '@material-ui/core/Button';
```

We have given you an example of adding a simple menu on the Ecommerce Dashboard.

![](https://3423697845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEnOfkACC-WsXr2rO7I%2F-Lbwg9fppjOWdgXHEgIf%2F-LbwglLrfwRCVKbvl_7B%2FSelection_041.png?alt=media\&token=8efbb588-5817-4fcb-95a5-30888d6f4dc5)

![Menu opened](https://3423697845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEnOfkACC-WsXr2rO7I%2F-Lbwg9fppjOWdgXHEgIf%2F-LbwgmxhNe3UXFkSKCGp%2FSelection_042.png?alt=media\&token=c191ec5a-410f-4ab8-948a-5a16d9723abc)

You can check some other layouts of menus below. For adding any of the below layout in the template, please check their relative code in the `src->routes->components->menu->component` folder.

![](https://3423697845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEnOfkACC-WsXr2rO7I%2F-LbvP11UgKU4MlVzPa8h%2F-LbvQjQFQBvJz6y9s40D%2FScreenshot%202019-04-08%20at%2011.00.06%20AM.png?alt=media\&token=e0618f8e-dd56-4f02-8cb7-34ddc794e6ab)
