UNPKG

4.2 kBMarkdownView Raw
1# [material-icons](https://github.com/marella/material-icons) [![Downloads](https://img.shields.io/npm/dm/material-icons)](https://www.npmjs.com/package/material-icons)
2
3Latest icon fonts and CSS for self-hosting material design icons.
4
5> This package is automatically updated, so it will always have the latest icons from Google.
6
7> For Material Symbols, see [`material-symbols`](https://www.npmjs.com/package/material-symbols)
8>
9> For SVGs, see [`@material-design-icons/svg`](https://www.npmjs.com/package/@material-design-icons/svg)
10
11- [Installation](#installation)
12- [Usage](#usage)
13- [Available Icons](#available-icons)
14
15## Installation
16
17Install the [latest version][releases] using:
18
19```sh
20npm install material-icons@latest
21```
22
23> **Note:** If you are upgrading from 0.x to 1.x see the [1.0.0 release notes](https://github.com/marella/material-icons/releases/tag/v1.0.0).
24
25## Usage
26
27Import in JS (example: `src/index.js` in Create React App, `src/main.js` in Vue CLI):
28
29```js
30import 'material-icons/iconfont/material-icons.css';
31```
32
33or import in CSS (example: `src/styles.css` in Angular CLI):
34
35```css
36@import 'material-icons/iconfont/material-icons.css';
37```
38
39or import in HTML:
40
41```html
42<link href="/path/to/material-icons/iconfont/material-icons.css" rel="stylesheet">
43```
44
45To display an icon, use one of the following:
46
47```html
48<span class="material-icons">pie_chart</span> <!-- Filled -->
49<span class="material-icons-outlined">pie_chart</span> <!-- Outlined -->
50<span class="material-icons-round">pie_chart</span> <!-- Round -->
51<span class="material-icons-sharp">pie_chart</span> <!-- Sharp -->
52<span class="material-icons-two-tone">pie_chart</span> <!-- Two Tone -->
53```
54
55### Reducing Build Size
56
57The default `material-icons.css` includes CSS for all fonts. This may cause build tools such as webpack to copy all fonts to the build directory even if you are not using all of them. To reduce the build size, import only the styles you need. For example, if you only need filled and outlined icons, import `filled.css` and `outlined.css` instead of the default `material-icons.css`:
58
59```diff
60-import 'material-icons/iconfont/material-icons.css';
61+import 'material-icons/iconfont/filled.css';
62+import 'material-icons/iconfont/outlined.css';
63```
64
65<details>
66<summary><strong>Show all</strong></summary><br>
67
68Icons | CSS | Sass
69:--- | :--- | :---
70Filled | filled.css | filled.scss
71Outlined | outlined.css | outlined.scss
72Round | round.css | round.scss
73Sharp | sharp.css | sharp.scss
74Two Tone | two-tone.css | two-tone.scss
75
76</details>
77
78### Using Sass
79
80Import in Sass (example: `src/styles.scss` in Angular CLI):
81
82```scss
83@import 'material-icons/iconfont/material-icons.scss';
84```
85
86Available Sass variables:
87
88```scss
89$material-icons-font-path: './' !default;
90$material-icons-font-size: 24px !default;
91$material-icons-font-display: block !default;
92```
93
94If you are getting errors with webpack or Vue CLI, add this line before importing:
95
96```scss
97$material-icons-font-path: '~material-icons/iconfont/';
98```
99
100### Using Angular `mat-icon`
101
102To display an icon, use one of the following:
103
104```html
105<mat-icon>pie_chart</mat-icon>
106<mat-icon fontSet="material-icons-outlined">pie_chart</mat-icon>
107<mat-icon fontSet="material-icons-round">pie_chart</mat-icon>
108<mat-icon fontSet="material-icons-sharp">pie_chart</mat-icon>
109<mat-icon fontSet="material-icons-two-tone">pie_chart</mat-icon>
110```
111
112### Using CSS Classes
113
114Alternatively, you may use CSS classes instead of ligatures to display icons. [Learn more](https://github.com/marella/material-icons/tree/main/css#readme)
115
116## Available Icons
117
118See [demo].
119
120## License
121
122Material design icons are created by [Google](https://github.com/google/material-design-icons#license).
123
124> We have made these icons available for you to incorporate into your products under the [Apache License Version 2.0][license]. Feel free to remix and re-share these icons and documentation in your products.
125We'd love attribution in your app's *about* screen, but it's not required.
126
127[releases]: https://github.com/marella/material-icons/releases
128[license]: https://github.com/marella/material-icons/blob/main/LICENSE
129[demo]: https://marella.github.io/material-icons/demo/