Skip to content

Commit 5241a93

Browse files
niels9001Copilot
andcommitted
Split color page: design guidance vs theming implementation
Consolidate Color Modes and Themes sections on the design color page, remove light/dark theme images (hero image remains), and remove all implementation content (changing theme, theme brushes, accent color overrides, color API). Create new 'Colors and themes' page under Develop > User Interface with all the implementation content: changing themes, theme brushes, accent color customization, accent color palette, and color API. Co-authored-by: Copilot <[email protected]>
1 parent cb1adbc commit 5241a93

3 files changed

Lines changed: 212 additions & 209 deletions

File tree

hub/apps/design/signature-experiences/color.md

Lines changed: 5 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ Windows employs color to help users focus on their tasks by indicating a visual
1515
> [!TIP]
1616
> This article describes how the [Fluent Design language](https://fluent2.microsoft.design/) is applied to Windows apps. For more information, see [**Fluent Design - Color**](https://fluent2.microsoft.design/color).
1717
18-
## Color modes
18+
## Color modes and themes
1919

2020
![Color hero image](images/color_hero_1880.png)
2121

22-
Windows supports two color modes, or themes: light and dark. Each mode consists of a set of neutral color values that are automatically adjusted to ensure optimal contrast.
22+
Windows supports two color modes, or themes: light and dark. Each mode consists of a set of neutral color values that are automatically adjusted to ensure optimal contrast. Windows apps can use a light or dark application theme, which affects the colors of the app's background, text, icons, and [common controls](../controls/index.md).
2323

2424
In both light and dark color modes, darker colors indicate background surfaces of less importance. Important surfaces are highlighted with lighter and brighter colors. See [layering & elevation](layering.md) for more information.
2525

26+
By default, your Windows app's theme is the user's theme preference from Windows Settings or the device's default theme. However, you can set the theme specifically for your app. To learn how to change themes, use theme brushes, and customize accent colors in code, see [Theming in Windows apps](../../develop/ui/theming.md).
27+
2628
## Accent color
2729

2830
:::row:::
@@ -43,14 +45,6 @@ Accent color is used to emphasize important elements in the user interface and t
4345
4446
[!INCLUDE [winui-3-gallery](../../../includes/winui-3-gallery.md)]
4547

46-
## Color in Windows apps
47-
48-
![hero image](../style/images/header-color.svg)
49-
50-
Color provides an intuitive way of communicating information to users in your app: it can be used to indicate interactivity, give feedback to user actions, and give your interface a sense of visual continuity.
51-
52-
In Windows apps, colors are primarily determined by accent color and theme. In this article, we'll discuss how you can use color in your app, and how to use accent color and theme resources to make your Windows app usable in any theme context.
53-
5448
## Color principles
5549

5650
:::row:::
@@ -75,205 +69,6 @@ Consider how the colors you use will be interpreted by people from different cul
7569
:::column-end:::
7670
:::row-end:::
7771

78-
## Themes
79-
80-
Windows apps can use a light or dark application theme. The theme affects the colors of the app's background, text, icons, and [common controls](../controls/index.md).
81-
82-
### Light theme
83-
84-
![light theme](../style/images/color/light-theme.svg)
85-
86-
### Dark theme
87-
88-
![dark theme](../style/images/color/dark-theme.svg)
89-
90-
By default, your Windows app's theme is the user’s theme preference from Windows Settings or the device's default theme. However, you can set the theme specifically for your Windows app.
91-
92-
### Changing the theme
93-
94-
You can change themes by changing the **RequestedTheme** property in your `App.xaml` file.
95-
96-
```XAML
97-
<Application
98-
x:Class="App9.App"
99-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
100-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
101-
xmlns:local="using:App9"
102-
RequestedTheme="Dark">
103-
</Application>
104-
```
105-
106-
Removing the **RequestedTheme** property means that your application will use the user’s system settings.
107-
108-
Users can also select the [high contrast theme](../accessibility/high-contrast-themes.md), which uses a small palette of contrasting colors that makes the interface easier to see. In that case, the system will override your RequestedTheme.
109-
110-
### Testing themes
111-
112-
If you don't request a theme for your app, make sure to test your app in both light and dark themes to ensure that your app will be legible in all conditions.
113-
114-
## Theme brushes
115-
116-
Common controls automatically use [theme brushes](../../develop/platform/xaml/xaml-theme-resources.md#the-xaml-color-ramp-and-theme-dependent-brushes) to adjust contrast for light and dark themes.
117-
118-
For example, here's an illustration of how the [AutoSuggestBox](../controls/auto-suggest-box.md) uses theme brushes:
119-
120-
![theme brushes control example](../style/images/color/theme-brushes.svg)
121-
122-
### Using theme brushes
123-
124-
:::row:::
125-
:::column:::
126-
When creating templates for custom controls, use theme brushes rather than hard code color values. This way, your app can easily adapt to any theme.
127-
128-
For example, these [item templates for ListView](../controls/item-templates-listview.md) demonstrate how to use theme brushes in a custom template.
129-
:::column-end:::
130-
:::column:::
131-
![double line list item with icon example](../style/images/color/list-view.svg)
132-
:::column-end:::
133-
:::row-end:::
134-
135-
```xaml
136-
<ListView ItemsSource="{x:Bind ViewModel.Recordings}">
137-
<ListView.ItemTemplate>
138-
<DataTemplate x:Name="DoubleLineDataTemplate" x:DataType="local:Recording">
139-
<StackPanel Orientation="Horizontal" Height="64" AutomationProperties.Name="{x:Bind CompositionName}">
140-
<Ellipse Height="48" Width="48" VerticalAlignment="Center">
141-
<Ellipse.Fill>
142-
<ImageBrush ImageSource="Placeholder.png"/>
143-
</Ellipse.Fill>
144-
</Ellipse>
145-
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Margin="12,0,0,0">
146-
<TextBlock Text="{x:Bind CompositionName}" Style="{ThemeResource BodyStrongTextBlockStyle}" Foreground="{ThemeResource TextFillColorPrimaryBrush}" />
147-
<TextBlock Text="{x:Bind ArtistName}" Style="{ThemeResource BodyTextBlockStyle}" Foreground="{ThemeResource TextFillColorTertiaryBrush}"/>
148-
</StackPanel>
149-
</StackPanel>
150-
</DataTemplate>
151-
</ListView.ItemTemplate>
152-
</ListView>
153-
```
154-
155-
For more information about how to use theme brushes in your app, see [Theme Resources](../../develop/platform/xaml/xaml-theme-resources.md).
156-
157-
## Accent colors
158-
159-
Common controls use an accent color to convey state information. By default, the accent color is the `SystemAccentColor` that users select in their Settings. However, you can also customize your app's accent color to reflect your brand.
160-
161-
![windows controls](../style/images/color/windows-controls.svg)
162-
163-
:::row:::
164-
:::column:::
165-
![user-selected accent header](../style/images/color/user-accent.svg)
166-
![user-selected accent color](../style/images/color/user-selected-accent.svg)
167-
:::column-end:::
168-
:::column:::
169-
![custom accent header](../style/images/color/custom-accent.svg)
170-
![custom brand accent color](../style/images/color/brand-color.svg)
171-
:::column-end:::
172-
:::row-end:::
173-
174-
### Overriding the accent color
175-
176-
To change your app's accent color, place the following code in `app.xaml`.
177-
178-
```xaml
179-
<Application.Resources>
180-
<ResourceDictionary>
181-
<Color x:Key="SystemAccentColor">#107C10</Color>
182-
</ResourceDictionary>
183-
</Application.Resources>
184-
```
185-
186-
### Choosing an accent color
187-
188-
If you select a custom accent color for your app, please make sure that text and backgrounds that use the accent color have sufficient contrast for optimal readability. To test contrast, you can use the color picker tool in Windows Settings, or you can use these [online contrast tools](https://www.w3.org/TR/WCAG20-TECHS/G18.html#G18-resources).
189-
190-
![Windows Settings custom accent color picker](../style/images/color/color-picker.svg)
191-
192-
## Accent color palette
193-
194-
An accent color algorithm in the Windows shell generates light and dark shades of the accent color.
195-
196-
![accent color palette](../style/images/color/accent-color-palette.svg)
197-
198-
These shades can be accessed as [theme resources](../../develop/platform/xaml/xaml-theme-resources.md):
199-
200-
- `SystemAccentColorLight3`
201-
- `SystemAccentColorLight2`
202-
- `SystemAccentColorLight1`
203-
- `SystemAccentColorDark1`
204-
- `SystemAccentColorDark2`
205-
- `SystemAccentColorDark3`
206-
207-
<!-- check this is true -->
208-
You can also access the accent color palette programmatically with the [**UISettings.GetColorValue**](/uwp/api/windows.ui.viewmanagement.uisettings.getcolorvalue) method and [**UIColorType**](/uwp/api/windows.ui.viewmanagement.uicolortype) enum.
209-
210-
You can use the accent color palette for color theming in your app. Below is an example of how you can use the accent color palette on a button.
211-
212-
![Accent color palette applied to a button](../style/images/color/color-theme-button.svg)
213-
214-
```xaml
215-
<Page.Resources>
216-
<ResourceDictionary>
217-
<ResourceDictionary.ThemeDictionaries>
218-
<ResourceDictionary x:Key="Light">
219-
<SolidColorBrush x:Key="ButtonBackground" Color="{ThemeResource SystemAccentColor}"/>
220-
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="{ThemeResource SystemAccentColorLight1}"/>
221-
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="{ThemeResource SystemAccentColorDark1}"/>
222-
</ResourceDictionary>
223-
</ResourceDictionary.ThemeDictionaries>
224-
</ResourceDictionary>
225-
</Page.Resources>
226-
227-
<Button Content="Button"></Button>
228-
```
229-
230-
When using colored text on a colored background, make sure there is enough contrast between text and background. By default, hyperlink or hypertext will use the accent color. If you apply variations of the accent color to the background, you should use a variation of the original accent color to optimize the contrast of colored text on a colored background.
231-
232-
The chart below illustrates an example of the various light/dark shades of accent color, and how colored type can be applied on a colored surface.
233-
234-
![Screenshot of the Color on Color chart that shows a color gradient from light blue on the top changing to a dark blue on the bottom.](../style/images/color/color-on-color.png)
235-
236-
For more information about styling controls, see [XAML styles](../../develop/platform/xaml/xaml-styles.md).
237-
238-
## Color API
239-
240-
There are several APIs that can be used to add color to your application. First, the [**Colors**](/uwp/api/windows.ui.colors) class, which implements a large list of predefined colors. These can be accessed automatically with XAML properties. In the example below, we create a button and set the background and foreground color properties to members of the **Colors** class.
241-
242-
```xaml
243-
<Button Background="MediumSlateBlue" Foreground="White">Button text</Button>
244-
```
245-
246-
You can create your own colors from RGB or hex values using the [**Color**](/uwp/api/windows.ui.color) struct in XAML.
247-
248-
```xaml
249-
<Color x:Key="LightBlue">#FF36C0FF</Color>
250-
```
251-
252-
You can also create the same color in code by using the **FromArgb** method.
253-
254-
```csharp
255-
Color LightBlue = Color.FromArgb(255,54,192,255);
256-
```
257-
```cppwinrt
258-
Windows::UI::Color LightBlue = Windows::UI::ColorHelper::FromArgb(255,54,192,255);
259-
```
260-
261-
The letters "Argb" stands for Alpha (opacity), Red, Green, and Blue, which are the four components of a color. Each argument can range from 0 to 255. You can choose to omit the first value, which will give you a default opacity of 255, or 100% opaque.
262-
263-
> [!Note]
264-
> If you're using C++, you must create colors by using the [**ColorHelper**](/uwp/api/windows.ui.colorhelper) class.
265-
266-
The most common use for a **Color** is as an argument for a [**SolidColorBrush**](/uwp/api/windows.ui.xaml.media.solidcolorbrush), which can be used to paint UI elements a single solid color. These brushes are generally defined in a [**ResourceDictionary**](/uwp/api/Windows.UI.Xaml.ResourceDictionary), so they can be reused for multiple elements.
267-
268-
```xaml
269-
<ResourceDictionary>
270-
<SolidColorBrush x:Key="ButtonBackgroundBrush" Color="#FFFF4F67"/>
271-
<SolidColorBrush x:Key="ButtonForegroundBrush" Color="White"/>
272-
</ResourceDictionary>
273-
```
274-
275-
For more information on how to use brushes, see [XAML brushes](../../develop/platform/xaml/brushes.md).
276-
27772
## Usability
27873

27974
:::row:::
@@ -313,6 +108,7 @@ Be aware of how colorblindness could affect the usability of your application. F
313108

314109
## Related
315110

111+
- [Theming in Windows apps](../../develop/ui/theming.md)
316112
- [XAML Styles](../../develop/platform/xaml/xaml-styles.md)
317113
- [XAML Theme Resources](../../develop/platform/xaml/xaml-theme-resources.md)
318114
- [WinUI Gallery - Colors](winui3gallery://item/Colors)

hub/apps/develop/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ items:
796796
href: ../winui/winui3/xaml-templated-controls-csharp-winui-3.md
797797
- name: Shadows
798798
href: ui/shadows.md
799+
- name: Colors and themes
800+
href: ui/theming.md
799801
- name: Alignment, margin, and padding
800802
href: ui/alignment-margin-padding.md
801803
- name: Layout panels

0 commit comments

Comments
 (0)