# Dialogs

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 dialog in the page where you want to add the component. Please check the code snippet given below, we have added the dialog in the Ecommerce Dashboard:

```
/**
 * Ecommerce Dashboard
 */

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

export default class EcommerceDashboard extends Component {
    
    // Dialog state
	state = {
      open: false
   }

   // Dialog Functions
   handleClickOpen() {
      this.setState({ open: true });
   };

   handleClose() {
      this.setState({ open: false });
   };
	render() {
				...
					<div className="col-sm-6 col-md-12 mb-30
					 ">
					    // Dialog Code
						<div>
							<Button variant="contained" onClick={() => this.handleClickOpen()} color="primary" className="text-white">Open alert dialog</Button>
							<Dialog open={this.state.open} onClose={() => this.handleClose()} aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description">
								<DialogTitle id="alert-dialog-title">{"Use Google's location service?"}</DialogTitle>
								<DialogContent>
									<DialogContentText id="alert-dialog-description">
										Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.
									</DialogContentText>
								</DialogContent>
								<DialogActions>
									<Button variant="contained" onClick={() => this.handleClose()} className="btn-danger text-white"> Disagree </Button>
									<Button variant="contained" onClick={() => this.handleClose()} color="primary" className="text-white" autoFocus> Agree </Button>
								</DialogActions>
							</Dialog>
						</div>
					</div>
				...	
```

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

```
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
```

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

![](https://3423697845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEnOfkACC-WsXr2rO7I%2F-LbwUY4w4XhkK6MIXG7o%2F-LbwVgSeBJK8XcjvFwx_%2FSelection_033.png?alt=media\&token=89c73b5a-11d6-4405-857e-2ebc9ac38739)

![Opened Dialog Box On Button Click](https://3423697845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEnOfkACC-WsXr2rO7I%2F-LbwUY4w4XhkK6MIXG7o%2F-LbwViQdp1tiA5yWCfnX%2FSelection_034.png?alt=media\&token=bf7dd820-6da8-4ce8-a4ef-299e9d1343aa)

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

![](https://3423697845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LEnOfkACC-WsXr2rO7I%2F-LbvF3BajKyaP0dTOUPN%2F-LbvGxd7Bg9Vs2_LaSgC%2FScreenshot%202019-04-08%20at%2010.13.37%20AM.png?alt=media\&token=a124eccf-c883-4728-af05-7834d0aa065f)
