8000 Added documentation for preference-based color scheme · squidfunk/mkdocs-material@143cb05 · GitHub
[go: up one dir, main page]

Skip to content

Commit 143cb05

Browse files
committed
Added documentation for preference-based color scheme
1 parent feda4ff commit 143cb05

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

docs/getting-started.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,16 @@ Click on a color name to change the color scheme of the theme:
365365
})
366366
</script>
367367

368+
The color scheme can also be set based on _user preference_, which makes use of
369+
the `prefers-color-scheme` media query. This can be done by adding the following
370+
to `mkdocs.yml`:
371+
372+
``` yaml
373+
theme:
374+
palette:
375+
scheme: preference
376+
```
377+
368378
### Color palette
369379

370380
The Material Design [color palette][10] comes with 20 hues, all of which are

material/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
{% else %}
8787
<body dir="{{ direction }}">
8888
{% endif %}
89-
{% if "prefers" == palette.scheme %}
89+
{% if "preference" == palette.scheme %}
9090
<script>matchMedia("(prefers-color-scheme: dark)").matches&&document.body.setAttribute("data-md-color-scheme","slate")</script>
9191
{% endif %}
9292
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">

src/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
{% endif %}
182182

183183
<!-- Experimental: set color scheme based on preference -->
184-
{% if "prefers" == palette.scheme %}
184+
{% if "preference" == palette.scheme %}
185185
<script>
186186
if (matchMedia("(prefers-color-scheme: dark)").matches)
187187
document.body.setAttribute("data-md-color-scheme", "slate")

0 commit comments

Comments
 (0)
0