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/classic-ui/theming/color-mode.md
+71-51Lines changed: 71 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,39 @@
1
-
# Color theme toggler for Bootstrap 5
2
-
With Bootstrap 5.3 a color-theme toggler is possible.
3
-
This is not provided by default and needs some custom code.
4
-
Here is a small guide how to implement it into Plone 6.
1
+
# Color Modes
2
+
Bootstrap 5.3 has introduced [Color Modes](https://getbootstrap.com/docs/5.3/customize/color-modes/).
3
+
Here is a small guide how to implement color themes in Plone 6.
4
+
5
+
## Preferred Color Modes
6
+
You will need to add some Javascript functionality to set the Bootstrap theme to the user's preferred color scheme.
7
+
Add the Javascript file to the `browser/static` folder of your Plone 6 project and register it in the `browser/profiles/default/registry` of your Plone 6 project.
8
+
See [Registering Javascript and CSS](classic-ui-static-resources-registering-label) for more information.
9
+
10
+
```js
11
+
(() => {
12
+
'use strict'
13
+
14
+
// Set Bootstrap Theme to the preferred color scheme
15
+
constsetPreferredTheme= () => {
16
+
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
@@ -18,74 +43,69 @@ If you want to add a theme toggler to your site, you can use the following eleme
18
43
</div>
19
44
```
20
45
21
-
## Javascript
46
+
## Registering the Toggle Button
47
+
48
+
You will need to add some Javascript functionality to the toggler.
49
+
The following code snippet is based on the [Bootstrap 5.3 documentation](https://getbootstrap.com/docs/5.3/customize/color-modes/#javascript).
22
50
23
-
The following Javascript is needed to make the toggler work.
24
-
It is based on the [Bootstrap 5.3 documentation](https://getbootstrap.com/docs/5.3/customize/color-modes/).
25
-
The Javascript is added to the `browser/static` folder of your Plone 6 project and registered in the `browser/profiles/default/registry` of your Plone 6 project.
51
+
Add the Javascript file to the `browser/static` folder of your Plone 6 project and register it in the `browser/profiles/default/registry` of your Plone 6 project.
26
52
See [Registering Javascript and CSS](classic-ui-static-resources-registering-label) for more information.
0 commit comments