Skip to content

Commit 901affa

Browse files
authored
[docs] Standardise the wording between icon docs and README (#12425)
Add a note about HMR performance.
1 parent a632bc9 commit 901affa

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

docs/src/pages/style/icons/icons.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ components: Icon, SvgIcon
66

77
<p class="description">Guidance and suggestions for using icons with Material-UI.</p>
88

9-
## System icons
10-
119
A [system icon](https://material.io/design/iconography/system-icons.html) or UI icon,
1210
symbolizes a command, file, device, or directory.
1311
System icons are also used to represent common actions like trash, print, and save,
1412
and are commonly found in app bars, toolbars, buttons, and lists.
1513
Google has provided a set of [Material icons](https://material.io/tools/icons/?style=baseline) that follow these guidelines.
1614

17-
Material-UI provides two components to render system icons: `Icon` for rendering font icons, and `SvgIcon` for rendering SVG paths.
15+
Material-UI provides two components to render system icons: `SvgIcon` for rendering SVG paths, and `Icon` for rendering font icons.
1816

19-
### SVG Icons
17+
## SVG Icons
2018

2119
The `SvgIcon` component takes an SVG `path` element as its child and converts it to a React component that displays the path,
2220
and allows the icon to be styled and respond to mouse events. SVG elements should be scaled for a 24x24px viewport.
@@ -28,7 +26,7 @@ Optionally, you can set the icon color using one of the theme color properties:
2826

2927
{{"demo": "pages/style/icons/SvgIcons.js"}}
3028

31-
#### SVG Material icons
29+
### SVG Material icons
3230

3331
It's interesting to have the building blocks needed to implement custom icons, but what about presets?
3432
We provide a separate NPM package,
@@ -39,6 +37,8 @@ that includes the 1,000+ official [Material icons](https://material.io/tools/ico
3937
<img src="/static/images/icons/icons.png" style="width: 566px" />
4038
</a>
4139

40+
#### Usage
41+
4242
You can use [material.io/tools/icons](https://material.io/tools/icons/?style=baseline) to find a specific icon.
4343
When importing an icon, keep in mind that the names of the icons are `PascalCase`, for instance:
4444
- [`delete`](https://material.io/tools/icons/?icon=delete&style=baseline) is exposed as `@material-ui/icons/Delete`
@@ -57,13 +57,29 @@ There are three exceptions to this rule:
5757

5858
{{"demo": "pages/style/icons/SvgMaterialIcons.js"}}
5959

60-
#### More SVG icons
60+
#### Imports
61+
62+
- If your environment doesn't support tree-shaking, the **recommended** way to import the icons is the following:
63+
```jsx
64+
import AccessAlarmIcon from '@material-ui/icons/AccessAlarm';
65+
import ThreeDRotation from '@material-ui/icons/ThreeDRotation';
66+
```
67+
68+
- If your environment support tree-shaking you can also import the icons this way:
69+
```jsx
70+
import { AccessAlarm, ThreeDRotation } from '@material-ui/icons';
71+
```
72+
73+
Note: Importing named exports in this way will result in the code for *every icon* being included in your project, so is not recommended unless you configure [tree-shaking](https://webpack.js.org/guides/tree-shaking/). It may also impact Hot Module Reload performance.
74+
75+
76+
### More SVG icons
6177

6278
Looking for even more SVG icons? There are a lot of projects out there,
6379
but [https://materialdesignicons.com](https://materialdesignicons.com/) provides over 2,000 official and community provided icons.
6480
[mdi-material-ui](https://github.com/TeamWertarbyte/mdi-material-ui) packages these icons as Material-UI SvgIcons in much the same way as [@material-ui/icons](https://www.npmjs.com/package/@material-ui/icons) does for the official icons.
6581

66-
### Font Icons
82+
## Font Icons
6783

6884
The `Icon` component will display an icon from any icon font that supports ligatures.
6985
As a prerequisite, you must include one, such as the
@@ -84,10 +100,10 @@ for example:
84100
By default, an Icon will inherit the current text color.
85101
Optionally, you can set the icon color using one of the theme color properties: `primary`, `secondary`, `action`, `error` & `disabled`.
86102

87-
#### Font Material icons
103+
### Font Material icons
88104

89105
{{"demo": "pages/style/icons/Icons.js"}}
90106

91-
#### [Font Awesome](https://fontawesome.com/icons)
107+
### [Font Awesome](https://fontawesome.com/icons)
92108

93109
{{"demo": "pages/style/icons/FontAwesome.js", "hideEditButton": true}}

packages/material-ui-icons/README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,36 @@ yarn add @material-ui/core
2525

2626
## Usage
2727

28-
The import path for each Material icon component includes the icon name in PascalCase.
28+
You can use [material.io/tools/icons](https://material.io/tools/icons/?style=baseline) to find a specific icon.
29+
When importing an icon, keep in mind that the names of the icons are `PascalCase`, for instance:
30+
- [`delete`](https://material.io/tools/icons/?icon=delete&style=baseline) is exposed as `@material-ui/icons/Delete`
31+
- [`delete forever`](https://material.io/tools/icons/?icon=delete_forever&style=baseline) is exposed as `@material-ui/icons/DeleteForever`
2932

30-
For example to use the 'access alarm' icon component, import `@material-ui/icons/AccessAlarm`.
31-
For "themed" icons, append the theme name to the icon name, for example `AccessAlarmOutlined`.
33+
For *"themed"* icons, append the theme name to the icon name. For instance with the
34+
- The Outlined [`delete`](https://material.io/tools/icons/?icon=delete&style=outline) icon is exposed as `@material-ui/icons/DeleteOutlined`
35+
- The Rounded [`delete`](https://material.io/tools/icons/?icon=delete&style=rounded) icon is exposed as `@material-ui/icons/DeleteRounded`
36+
- The Two Tone [`delete`](https://material.io/tools/icons/?icon=delete&style=twotone) icon is exposed as `@material-ui/icons/DeleteTwoTone`
37+
- The Sharp [`delete`](https://material.io/tools/icons/?icon=delete&style=sharp) icon is exposed as `@material-ui/icons/DeleteSharp`
3238

33-
Note, there are three exceptions:
34-
- '3d rotation' is named `ThreeDRotation`
35-
- '4k' is named `FourK`
36-
- '360' is named `ThreeSixty`
39+
There are three exceptions to this rule:
40+
- [`3d_rotation`](https://material.io/tools/icons/?icon=3d_rotation&style=baseline) is exposed as `@material-ui/icons/ThreeDRotation`
41+
- [`4k`](https://material.io/tools/icons/?icon=4k&style=baseline) is exposed as `@material-ui/icons/FourK`
42+
- [`360`](https://material.io/tools/icons/?icon=360&style=baseline) is exposed as `@material-ui/icons/ThreeSixty`
3743

38-
### Examples
44+
## Imports
3945

4046
- If your environment doesn't support tree-shaking, the **recommended** way to import the icons is the following:
4147
```jsx
4248
import AccessAlarmIcon from '@material-ui/icons/AccessAlarm';
4349
import ThreeDRotation from '@material-ui/icons/ThreeDRotation';
4450
```
4551

46-
- If your environment support tree-shaking you can also import the icons that way:
52+
- If your environment support tree-shaking you can also import the icons this way:
4753
```jsx
4854
import { AccessAlarm, ThreeDRotation } from '@material-ui/icons';
4955
```
5056

51-
Note: Importing named exports in this way will result in the code for *every icon* being included in your project, so is not recommended unless you configure [tree-shaking](https://webpack.js.org/guides/tree-shaking/).
57+
Note: Importing named exports in this way will result in the code for *every icon* being included in your project, so is not recommended unless you configure [tree-shaking](https://webpack.js.org/guides/tree-shaking/). It may also impact Hot Module Reload performance.
5258

5359
## Upgrading
5460

0 commit comments

Comments
 (0)