
The role="img" attribute and the element are added so that your icons are correctly accessible. You should include the titleAccess prop with a meaningful value.

The aria-hidden=true attribute is added so that your icons are properly accessible (invisible). If your icons are purely decorative, you're already done! This includes icons without text next to them that are used as interactive controls - buttons, form elements, toggles, etc.
Material design icons code#
Whenever possible SVG is preferred as it allows code splitting, supports more icons, and renders faster and better.įor more details, take a look at why GitHub migrated from font icons to SVG icons. There are three exceptions to this naming rule: 3d_rotation exported as ThreeDRotation, 4k exported as FourK, and 360 exported as ThreeSixty.īoth approaches work fine, however there are some subtle differences, especially in terms of performance and rendering quality.

To import the icon component with a theme other than the default, append the theme name to the icon name.

Make sure you follow the minimizing bundle size guide before using the second approach.Įach Material icon also has a "theme": Filled (default), Outlined, Rounded, Two-tone, and Sharp. Icons are quite the challenge to design: they have to be meaningful and beautiful, all the while being understandable in a split second. The safest for bundle size is Option 1, but some developers prefer Option 2.
