Skip to content

Commit f2bbb26

Browse files
Adds information about fullPageAppIconImageUrl (SharePoint#5994)
* Adds information about fullPageAppIconImageUrl * Adds 1px border to images
1 parent 3db82c6 commit f2bbb26

File tree

3 files changed

+66
-9
lines changed

3 files changed

+66
-9
lines changed
94.4 KB
Loading

docs/images/webparticon-toolbox.png

51.2 KB
Loading

docs/spfx/web-parts/basics/configure-web-part-icon.md

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@ localization_priority: Priority
88

99
# Configure web part icon
1010

11-
Selecting an icon that illustrates the purpose of your SharePoint client-side web part makes it easier for users to find your web part among other all web parts available in the toolbox.
11+
Selecting an icon that illustrates the purpose of your SharePoint client-side web part makes it easier for users to find your web part among all other web parts available in the toolbox or when creating [single part app pages](../single-part-app-pages.md).
1212

1313
## Preconfigure web parts
1414

1515
A web part icon is defined in the web part manifest as part of preconfigured entries. If you have a multipurpose web part that can be configured to meet different needs, each configuration can have a different icon indicating its purpose.
1616

1717
Using a representative icon helps users find the web part they're looking for. For more information about preconfiguring your web parts, see [Simplify adding web parts with preconfigured entries](../guidance/simplify-adding-web-parts-with-preconfigured-entries.md).
1818

19-
SharePoint Framework offers you a number of ways to define the icon for your web part.
19+
In the web part manifest you can configure the web part icon displayed in the toolbox and a preview image displayed when creating single part app pages.
2020

21-
## Use Fluent UI icon font
21+
## Specify toolbox icon
22+
23+
Toolbox icon is displayed when in the web part toolbox, when users choose to add a web part to the page.
24+
25+
![Web part toolbox visible on a modern page](../../../images/webparticon-toolbox.png)
26+
27+
SharePoint Framework offers you a number of ways to define the toolbox icon for your web part.
28+
29+
### Use Fluent UI icon font
2230

2331
One way to define the icon for your web part is by using the `officeFabricIconFontName` property. This property allows you to choose one of the icons offered as a part of Fluent UI.
2432

2533
For a list of available Fluent UI icons, see [Icons](https://developer.microsoft.com/fluentui#/styles/web/icons).
2634

27-
### To use a specific icon
35+
#### To use a specific icon
2836

2937
1. On the Fluent UI icons overview page, copy its name, and paste it as the value of the `officeFabricIconFontName` property in the manifest of your web part.
3038

@@ -68,13 +76,13 @@ For a list of available Fluent UI icons, see [Icons](https://developer.microsoft
6876

6977
The benefit of this approach is that you don't need to deploy the icon image file along with your web part assets. Additionally, on computers using different DPI or other accessibility settings, the icon automatically adapts to these settings without losing quality.
7078

71-
## Use an external icon image
79+
### Use an external icon image
7280

7381
Although Fluent UI offers many images, when building web parts you might want to use something specific to your organization to clearly separate your web parts from other first and third-party web parts visible in the toolbox.
7482

7583
In addition to using Fluent UI icons, the SharePoint Framework also allows you to use images.
7684

77-
### To use an image as a web part icon
85+
#### To use an image as a web part icon
7886

7987
1. Specify the image's absolute URL in the `iconImageUrl` property in the web part manifest.
8088

@@ -116,13 +124,13 @@ In addition to using Fluent UI icons, the SharePoint Framework also allows you t
116124

117125
While using custom images gives you more flexibility to choose an icon for your web part, it requires you to deploy them along with your other web part assets. Additionally, your image might lose quality when displayed in higher DPI or specific accessibility settings. To avoid quality loss, you can use vector-based SVG images, which are also supported by the SharePoint Framework.
118126

119-
## Use a base64-encoded image
127+
### Use a base64-encoded image
120128

121129
When using a custom image, rather than specifying an absolute URL to the image file hosted together with other web part assets, you can have your image base64-encoded and use the base64 string instead of the URL.
122130

123131
A number of services are available online that you can use to base64-encode your image; for more information, see [Convert your images to Base64](https://www.base64-image.de).
124132

125-
### To use a base64-encoded image
133+
#### To use a base64-encoded image
126134

127135
1. Encode the image.
128136
1. Copy the base64 string and use it as the value for the `iconImageUrl` property in the web part manifest.
@@ -163,8 +171,57 @@ Base64 encoding works for both bitmap images, such as PNG, and vector SVG images
163171

164172
![Base64-encoded image displayed as web part icon in the toolbox](../../../images/webparticon_toolbox_base64.png)
165173

166-
## Additional considerations
174+
### Additional considerations
167175

168176
Each web part must have an icon. If you specify the web part icon by using both the `officeFabricIconFontName` and the `iconImageUrl` properties, the icon specified in the `officeFabricIconFontName` is used.
169177

170178
If you choose not to use a Fluent UI icon, you have to specify a URL in the `iconImageUrl` property.
179+
180+
## Set the single part app page preview image
181+
182+
Starting from SharePoint Framework v1.11 you can specify the preview image for your web part that's displayed when users create a single part app page.
183+
184+
![Web part's single part app page preview image displayed when creating a single part app page](../../../images/webparticon-fullpageappicon.png)
185+
186+
> [!CAUTION]
187+
> At this moment, the single part app page image can be set only to an image URL. Using base64-encoded images is currently not supported.
188+
189+
### To set the single part app page preview image
190+
191+
Specify the image's absolute URL in the `fullPageAppIconImageUrl` property in the web part manifest.
192+
193+
```json
194+
{
195+
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
196+
"id": "bcae7077-85cb-41a0-b3d3-2084f268a211",
197+
"alias": "WeatherWebPart",
198+
"componentType": "WebPart",
199+
200+
"version": "*",
201+
"manifestVersion": 2,
202+
203+
"requiresCustomScript": false,
204+
"preconfiguredEntries": [
205+
{
206+
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
207+
"group": {
208+
"default": "Other"
209+
},
210+
"title": {
211+
"default": "Weather"
212+
},
213+
"description": {
214+
"default": "Shows current weather in the given ___location"
215+
},
216+
"officeFabricIconFontName": "Sunny",
217+
"fullPageAppIconImageUrl": "https://assets.contoso.com/fullPageAppIcon.png",
218+
"properties": {
219+
"___location": "Munich"
220+
}
221+
}
222+
]
223+
}
224+
```
225+
226+
> [!TIP]
227+
> When displayed in the browser, the image will adjust its size based on the current screen size. By default, the image dimensions are 193x158px, where the bottom 48px are partially covered by the label with the web part's name. On smaller screens, the size and dimension of the displayed image will vary and the label with the web part's name can cover a relatively larger portion of the image.

0 commit comments

Comments
 (0)