1 | # @uifabric/icons
|
2 |
|
3 | **Icons for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)**
|
4 | ([formerly Office UI Fabric React](https://developer.microsoft.com/en-us/office/blogs/ui-fabric-is-evolving-into-fluent-ui/))
|
5 |
|
6 | Fluent UI React Icons includes a collection of 1100+ icons which you can use in your application.
|
7 |
|
8 | ## Getting started
|
9 |
|
10 | If you are using Fluent UI React components, you can make all icons available by calling the `initializeIcons` function from the `@uifabric/icons` package:
|
11 |
|
12 | ```tsx
|
13 | import { initializeIcons } from '@uifabric/icons';
|
14 |
|
15 | // Register icons and pull the fonts from the default SharePoint cdn.
|
16 | initializeIcons();
|
17 |
|
18 | // ...or, register icons and pull the fonts from your own cdn:
|
19 | initializeIcons('https://my.cdn.com/path/to/icons/');
|
20 | ```
|
21 |
|
22 | This will make ALL icons in the collection available, but will download them on demand when referenced using the `@uifabric/styling` APIs `getIcon` or `getIconClassName`.
|
23 |
|
24 | ## Usage in code
|
25 |
|
26 | ### Icon component
|
27 |
|
28 | If you are using Fluent UI React, you can use the `Icon` component and pass in the corresponding iconName property to render a given icon.
|
29 |
|
30 | ```tsx
|
31 | import { Icon } from '@fluentui/react/lib/Icon';
|
32 |
|
33 | <Icon iconName="Snow" />;
|
34 | ```
|
35 |
|
36 | ### `getIconClassName` API
|
37 |
|
38 | The styling package includes a `getIconClassName` API which can provide a css class to use for rendering the icon manually using the `:before` pseudoselector:
|
39 |
|
40 | ```ts
|
41 | import { getIconClassName } from '@uifabric/styling';
|
42 |
|
43 | return `<i class="${getIconClassName('Snow')}" />`;
|
44 | ```
|
45 |
|
46 | ## Notes
|
47 |
|
48 | See [GitHub](https://github.com/microsoft/fluentui) for more details on the Fluent UI React project and packages within.
|