Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React: Using Material UI Icons as a button?

Tags:

reactjs

I'm a newb to React and front-end development and I recently started playing with Material UI. Is there a way to hook an icon to an action?

I'm looking for something like this:

<DeleteIcon onClick={this.handleClick} />

Thanks for your help!

like image 557
Tim Avatar asked Sep 10 '18 21:09

Tim


1 Answers

Wrap the DeleteIcon in an IconButton:

<IconButton onClick={this.handleClick}>
   <DeleteIcon/>
</IconButton>

Look here for more details: https://material-ui.com/api/icon-button/

like image 185
Cody S Avatar answered Sep 19 '22 12:09

Cody S