|
| 1 | +--- |
| 2 | +title: Customize the widget header area |
| 3 | +description: Learn how to customize the header area of a Windows widget. |
| 4 | +ms.topic: article |
| 5 | +ms.date: 11/12/2024 |
| 6 | +ms.localizationpriority: medium |
| 7 | +--- |
| 8 | + |
| 9 | +# Customize the widget header area |
| 10 | + |
| 11 | +Starting with Windows build [TBD - Build number], apps that implement Windows widgets can customize the header that is displayed for their widget in the Widgets Board, overriding the default presentation. Header customization is implemented in the Adaptive Card payload you pass to the OS from your widget provider, so the steps are the same regardless of the language your widget provider is implemented in. For a walkthrough of creating a widget provider, see [Implement a widget provider in a C# Windows App](implement-widget-provider-cs.md) or [Implement a widget provider in a win32 app (C++/WinRT)](implement-widget-provider-win32.md). |
| 12 | + |
| 13 | +## The default header |
| 14 | + |
| 15 | +By default, the widget header shows the display name and the icon specified in the app manifest file. The display name is specified with the **DisplayName** attribute of the **Definition** element and the icon is specified with an **Icon** element under **ThemeResources**. For more information about the widget app manifest file format, see [Widget provider package manifest XML format](widget-provider-manifest.md). |
| 16 | + |
| 17 | +The following example shows a portion of the Adaptive Card JSON payload for a widget that uses the default presentation. In the sections below, examples will be provided that modify this template to override the default header. |
| 18 | + |
| 19 | +```json |
| 20 | +{ |
| 21 | + "type": "AdaptiveCard", |
| 22 | + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", |
| 23 | + "version": "1.6", |
| 24 | + "body": [ |
| 25 | + ... |
| 26 | + ] |
| 27 | + } |
| 28 | +``` |
| 29 | + |
| 30 | +## Override the display name string |
| 31 | + |
| 32 | +You can override the value specified in the **DisplayName** element in the app manifest by adding a `header` field to with the new display name in the JSON payload before sending it to the widget host. |
| 33 | + |
| 34 | +The following example demonstrates overriding the display name string. |
| 35 | + |
| 36 | +```json |
| 37 | +{ |
| 38 | + "type": "AdaptiveCard", |
| 39 | + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", |
| 40 | + "version": "1.6", |
| 41 | + "body": [ |
| 42 | + ... |
| 43 | + ] , |
| 44 | + "header": "Redmond Weather" |
| 45 | + } |
| 46 | +``` |
| 47 | + |
| 48 | +## Override the display name string and icon |
| 49 | + |
| 50 | +To override both the display name string and the icon specified in the app manifest, add a `header` object with fields for `text` and `iconUrl`. |
| 51 | + |
| 52 | +The following example demonstrates overriding the display name string and icon. |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "type": "AdaptiveCard", |
| 57 | + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", |
| 58 | + "version": "1.6", |
| 59 | + "body": [ |
| 60 | + ... |
| 61 | + ] , |
| 62 | + "header": { |
| 63 | + "text": "Redmond weather", |
| 64 | + "iconUrl": "https://contoso.com/weatherimage.png" |
| 65 | + } |
| 66 | + } |
| 67 | +``` |
| 68 | + |
| 69 | +## Set the header to be empty |
| 70 | + |
| 71 | +Some widget providers may want to allow their full UX to expand into the header region of the widget, even though this area of the widget isn't actionable. For this scenario, you can set the header to be empty by setting the `header` feel to `null`. Note that the UX in the header is not clickable by the user. |
| 72 | + |
| 73 | +The following example demonstrates setting an empty header. |
| 74 | + |
| 75 | +```json |
| 76 | +{ |
| 77 | + "type": "AdaptiveCard", |
| 78 | + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", |
| 79 | + "version": "1.6", |
| 80 | + "body": [ |
| 81 | + ... |
| 82 | + ] , |
| 83 | + "header": null |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +## Override the header with Adaptive Card content |
| 88 | + |
| 89 | +You can overwrite the header with UI components defined using the Adaptive Card schema. The specified content will be rendered within the 48px high header area. |
| 90 | + |
| 91 | +The following example uses Adaptive Card components to render a combo box selector in the widget header. |
| 92 | + |
| 93 | +```json |
| 94 | +{ |
| 95 | + "type": "AdaptiveCard", |
| 96 | + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", |
| 97 | + "version": "1.6", |
| 98 | + "body": [ |
| 99 | + ... |
| 100 | + ] , |
| 101 | + "header": [ |
| 102 | + { |
| 103 | + "type": "Input.ChoiceSet", |
| 104 | + "id": "WeatherSwitcher", |
| 105 | + "choices": [ |
| 106 | + { |
| 107 | + "title": "Redmond", |
| 108 | + "value": "Redmond" |
| 109 | + }, |
| 110 | + { |
| 111 | + "title": "Bellevue", |
| 112 | + "value": "Bellevue" |
| 113 | + } |
| 114 | + ], |
| 115 | + "placeholder": "Pick location", |
| 116 | + "value": "Bellevue" |
| 117 | + } |
| 118 | + ] |
| 119 | +} |
| 120 | +``` |
0 commit comments