UNPKG

1.65 kBMarkdownView Raw
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
6Fluent UI React Icons includes a collection of 1100+ icons which you can use in your application.
7
8## Getting started
9
10If 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
13import { initializeIcons } from '@uifabric/icons';
14
15// Register icons and pull the fonts from the default SharePoint cdn.
16initializeIcons();
17
18// ...or, register icons and pull the fonts from your own cdn:
19initializeIcons('https://my.cdn.com/path/to/icons/');
20```
21
22This 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
28If 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
31import { Icon } from '@fluentui/react/lib/Icon';
32
33<Icon iconName="Snow" />;
34```
35
36### `getIconClassName` API
37
38The 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
41import { getIconClassName } from '@uifabric/styling';
42
43return `<i class="${getIconClassName('Snow')}" />`;
44```
45
46## Notes
47
48See [GitHub](https://github.com/microsoft/fluentui) for more details on the Fluent UI React project and packages within.