You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spfx/use-theme-colors-in-your-customizations.md
+30-40Lines changed: 30 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,15 @@
1
1
---
2
2
title: Use theme colors in your SharePoint Framework customizations
3
3
description: Use theme colors so that your customizations look like a part of the site by referring to the theme colors of the context site in your SharePoint Framework solution.
4
-
ms.date: 01/24/2018
4
+
ms.date: 10/22/2019
5
5
ms.prod: sharepoint
6
6
localization_priority: Priority
7
7
---
8
-
9
-
10
8
# Use theme colors in your SharePoint Framework customizations
11
9
12
10
When building SharePoint Framework customizations, you should use theme colors so that your customizations look like a part of the site. This article explains how can you refer to the theme colors of the context site in your SharePoint Framework solution.
13
11
14
-
> [!NOTE]
12
+
> [!NOTE]
15
13
> Although this article uses a SharePoint Framework client-side web part as an example, the described techniques apply to all types of SharePoint Framework customizations.
16
14
17
15
## Fixed colors vs. theme colors
@@ -30,49 +28,45 @@ When working with fixed colors, you specify them in CSS properties, for example:
30
28
31
29
```css
32
30
.button {
33
-
background-color: #0078d7;
31
+
background-color: #0078d7;
34
32
}
35
33
```
36
34
37
-
<br/>
38
-
39
35
To use a theme color instead, replace the fixed color with a theme token:
When your SharePoint Framework customization is loading on the page, the **\@microsoft/load-themed-styles** package, which is a part of the SharePoint Framework, looks for theme tokens in CSS files and tries to replace them with the corresponding color from the current theme. If the value for the specified token is not available, SharePoint Framework uses the value specified by using the **default** parameter instead, which is why it's important that you always include it.
50
44
51
45
The following theme tokens are available for you to use:
52
46
53
-
Token|Default value on a modern team site using the red palette|Remarks
|`themeDark`|`#b3030c`|Used for action icons in the command bar and as a hover color.|
52
+
|`themeDarkAlt`|`#b3030c`||
53
+
|`themeDarker`|`#770208`||
54
+
|`themeLight`|`#fd969b`||
55
+
|`themeLightAlt`|`#fd969b`||
56
+
|`themeLighter`|`#fecacd`||
57
+
|`themeLighterAlt`|`#fecacd`||
58
+
|`themePrimary`|`#ee0410`|Primary theme color. Used for icons and default buttons.|
59
+
|`themeSecondary`|`#fc6169`||
60
+
|`themeTertiary`|`#fd969b`||
61
+
62
+
> [!NOTE]
69
63
> There are more tokens registered with the SharePoint Framework. While all of them have values specified on classic sites, only the subset mentioned earlier has values on modern SharePoint sites. For the complete list of available tokens, see the value of the `window.__themeState__.theme` property by using the console in your web browser's developer tools.
70
64
71
65
## Use theme colors in your customizations
72
66
73
67
When you scaffold a new SharePoint Framework client-side web part, by default, it uses the fixed blue palette. The following steps describe the necessary adjustments to have the web part use theme colors instead.
74
68
75
-
> [!NOTE]
69
+
> [!NOTE]
76
70
> The following steps apply to a SharePoint Framework client-side web part named _HelloWorld_ built by using React. For web parts built using different libraries and other types of customizations, you might need to adjust the modifications accordingly.
77
71
78
72
### To use theme colors
@@ -81,35 +75,31 @@ When you scaffold a new SharePoint Framework client-side web part, by default, i
81
75
82
76

83
77
84
-
2. In the same folder, open the **HelloWorld.module.scss** file. Change the `.row` selector to:
78
+
1. In the same folder, open the **HelloWorld.module.scss** file. Change the `.row` selector to:

111
101
112
-
4. When you add the web part to a site, the colors used by the web part automatically adapt to the theme colors used by the current site.
102
+
1. When you add the web part to a site, the colors used by the web part automatically adapt to the theme colors used by the current site.
113
103
114
104

0 commit comments