mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added documentation for preference-based color scheme
This commit is contained in:
parent
feda4ff29a
commit
143cb05e97
@ -365,6 +365,16 @@ Click on a color name to change the color scheme of the theme:
|
||||
})
|
||||
</script>
|
||||
|
||||
The color scheme can also be set based on _user preference_, which makes use of
|
||||
the `prefers-color-scheme` media query. This can be done by adding the following
|
||||
to `mkdocs.yml`:
|
||||
|
||||
``` yaml
|
||||
theme:
|
||||
palette:
|
||||
scheme: preference
|
||||
```
|
||||
|
||||
### Color palette
|
||||
|
||||
The Material Design [color palette][10] comes with 20 hues, all of which are
|
||||
|
@ -86,7 +86,7 @@
|
||||
{% else %}
|
||||
<body dir="{{ direction }}">
|
||||
{% endif %}
|
||||
{% if "prefers" == palette.scheme %}
|
||||
{% if "preference" == palette.scheme %}
|
||||
<script>matchMedia("(prefers-color-scheme: dark)").matches&&document.body.setAttribute("data-md-color-scheme","slate")</script>
|
||||
{% endif %}
|
||||
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
||||
|
@ -181,7 +181,7 @@
|
||||
{% endif %}
|
||||
|
||||
<!-- Experimental: set color scheme based on preference -->
|
||||
{% if "prefers" == palette.scheme %}
|
||||
{% if "preference" == palette.scheme %}
|
||||
<script>
|
||||
if (matchMedia("(prefers-color-scheme: dark)").matches)
|
||||
document.body.setAttribute("data-md-color-scheme", "slate")
|
||||
|
Loading…
Reference in New Issue
Block a user