React JS - React Material UI icons not working?

Viewed 17835

I am using react Material UI, and I received the following error.

"Module not found: Can't resolve '@material-ui/icons/Lock'"

import LockIcon from '@material-ui/icons/Lock';

How can I fix this?

4 Answers
import Icon from '@material-ui/core/Icon';

then add font material icons to index.html

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

You haven't installed @material-ui/icons package. You can validate it from node_modules


This would resolve your issue,

npm install --save @material-ui/icons

Here's an alternative is you cant install the node modules:

  1. Add "" to your head tag, or whever you store your links to style sheets.
  2. Add a span tag with class name "material-icons" and make the content of the span the icon you want to use. example: menu

You can find more info about all the icons here

Related