|
| 1 | +# IconPicker control |
| 2 | + |
| 3 | +Control that allows to search and select an icon from office-ui-fabric-react icons. |
| 4 | + |
| 5 | +## Overview |
| 6 | +The control allows selecting an icon from the list of icons available in the office-ui-fabric-react library. Icon list is a static copy of available icons. Currently, only one icon selection is supported. |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +## Displayed in the panel |
| 11 | +Icon picker always opens a new panel where you can pick an icon. The panel displays all the icons and maintains readability. Picker does not displays selected icon outside the panel. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +## How to use this control |
| 16 | + |
| 17 | +- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../../#getting-started) page for more information about installing the dependency. |
| 18 | +- Import the following module to your component: |
| 19 | + |
| 20 | +```TypeScript |
| 21 | +import { IconPicker } from '@pnp/spfx-controls-react/lib/IconPicker'; |
| 22 | +``` |
| 23 | + |
| 24 | +- Use the `IconPicker` control in your code as follows: |
| 25 | + |
| 26 | +```TypeScript |
| 27 | +<IconPicker |
| 28 | + buttonLabel={'Icon'} |
| 29 | + onChange={(iconName: string) => { this.setState({icon: iconName}); }} |
| 30 | + onSave={(iconName: string) => { this.setState({icon: iconName}); }} |
| 31 | +/> |
| 32 | +``` |
| 33 | + |
| 34 | +## Implementation |
| 35 | + |
| 36 | +The IconPicker component can be configured with the following properties: |
| 37 | + |
| 38 | +| Property | Type | Required | Description | |
| 39 | +| ---- | ---- | ---- | ---- | |
| 40 | +| buttonLabel | string | no | Specifies the label of the icon picker button. | |
| 41 | +| onSave | (iconName: string) => void | yes | Handler when the icon has been selected and picker has been closed. | |
| 42 | +| onChange | (iconName: string) => void | no | Handler when the icon selection has been changed. | |
| 43 | +| disabled | boolean | no | Specifies if the picker button is disabled | |
| 44 | +| buttonClassName | boolean | no | If provided, additional class name will be added to the picker button | |
| 45 | +| panelClassName | boolean | no | If provided, additional class name will be added to the picker panel | |
| 46 | +| currentIcon | boolean | no | Specifies default selected icon | |
| 47 | + |
| 48 | + |
0 commit comments