Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit ab19eca

Browse files
author
Matt Goo
authored
docs: add best practices doc on icons (#238)
1 parent 69e4efe commit ab19eca

File tree

9 files changed

+48
-0
lines changed

9 files changed

+48
-0
lines changed

docs/best-practices.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Importing Font Icons
2+
3+
If you need to import font icons to your app, the best way is to include it as a `<link>` tag in the head of your document. For example if you're using Material Icons you would add this to your `<head>`:
4+
5+
```html
6+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
7+
rel="stylesheet">
8+
```
9+
10+
Further details documented on [Material Icons docs ](https://google.github.io/material-design-icons/#icon-font-for-the-web).
11+
12+
By not including the font icon inside your CSS file, it reduces the file size. By reducing CSS file size, you decrease the time to initial load since CSS files are render blocking. This does present some drawbacks -- the main issue being FOUC (Flash of unstyled content). Your users will not see the actual icons until the font icon file loads.
13+
14+
### Use with MDC Ripple
15+
16+
If you load your font icons with a [Ripple](../packages/ripple) with the above method, you will need to set the height and width of the icons. This is because MDC Ripple calculates the ripple size from the initial height/width.

packages/button/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ Sass mixins may be available to customize various aspects of the Components. Ple
5757
MDC Web repository for more information on what mixins are available, and how to use them.
5858

5959
[Advanced Sass Mixins](https://github.com/material-components/material-components-web/blob/master/packages/mdc-button/README.md#sass-mixins)
60+
61+
## Usage with Icons
62+
63+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) when importing or using icon fonts.

packages/card/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,7 @@ Sass mixins may be available to customize various aspects of the Components. Ple
165165
MDC Web repository for more information on what mixins are available, and how to use them.
166166

167167
[Advanced Sass Mixins](https://github.com/material-components/material-components-web/blob/master/packages/mdc-card/README.md#sass-mixins)
168+
169+
## Usage with Icons
170+
171+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) when importing or using icon fonts.

packages/fab/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ Sass mixins may be available to customize various aspects of the components. Ple
5757
MDC Web repository for more information on what mixins are available, and how to use them.
5858

5959
[Advanced Sass Mixins](https://github.com/material-components/material-components-web/blob/master/packages/mdc-fab/README.md#advanced-sass-mixins)
60+
61+
## Usage with Icons
62+
63+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) when importing or using icon fonts.

packages/material-icon/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ Prop Name | Type | Description
5555
icon | string | Type of icon to be displayed.
5656
className | string | Classes to pass on to the root `<i>` element.
5757
hasRipple | n/a | If present on element, it will enable the ripple on the icon.
58+
59+
## Usage with Icons
60+
61+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) for further reading.

packages/tab-indicator/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@ Sass mixins may be available to customize various aspects of the components. Ple
8888
MDC Web repository for more information on what mixins are available, and how to use them.
8989

9090
[Advanced Sass Mixins](https://github.com/material-components/material-components-web/blob/master/packages/mdc-tab-indicator/README.md#sass-mixins)
91+
92+
## Usage with Icons
93+
94+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) when importing or using icon fonts.

packages/tab/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ Sass mixins may be available to customize various aspects of the components. Ple
9090
MDC Web repository for more information on what mixins are available, and how to use them.
9191

9292
[Advanced Sass Mixins](https://github.com/material-components/material-components-web/blob/master/packages/mdc-tab/README.md#sass-mixins)
93+
94+
## Usage with Icons
95+
96+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) when importing or using icon fonts.

packages/text-field/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,7 @@ Sass mixins may be available to customize various aspects of the Components. Ple
113113
MDC Web repository for more information on what mixins are available, and how to use them.
114114

115115
[Advanced Sass Mixins](https://github.com/material-components/material-components-web/blob/master/packages/mdc-textfield/README.md)
116+
117+
## Usage with Icons
118+
119+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) when importing or using icon fonts.

packages/top-app-bar/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,7 @@ Sass mixins may be available to customize various aspects of the Components. Ple
9292
MDC Web repository for more information on what mixins are available, and how to use them.
9393

9494
[Advanced Sass Mixins](https://github.com/material-components/material-components-web/blob/master/packages/mdc-top-app-bar/README.md#sass-mixins)
95+
96+
## Usage with Icons
97+
98+
Please see our [Best Practices doc](../../docs/best-practices.md#importing-font-icons) when importing or using icon fonts.

0 commit comments

Comments
 (0)