2020-07-21 17:01:22 +03:00
|
|
|
|
# Changing the colors
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2020-07-26 15:46:09 +03:00
|
|
|
|
As any proper Material Design implementation, Material for MkDocs supports
|
2023-09-14 20:09:18 +03:00
|
|
|
|
Google's original [color palette], which can be easily configured through
|
2020-07-17 14:08:27 +03:00
|
|
|
|
`mkdocs.yml`. Furthermore, colors can be customized with a few lines of CSS to
|
2021-10-10 18:39:53 +03:00
|
|
|
|
fit your brand's identity by using [CSS variables][custom colors].
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
[color palette]: http://www.materialui.co/colors
|
|
|
|
|
[custom colors]: #custom-colors
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
2020-08-27 00:21:28 +03:00
|
|
|
|
### Color palette
|
|
|
|
|
|
|
|
|
|
#### Color scheme
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:version 5.2.0 -->
|
|
|
|
|
<!-- md:default `default` -->
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2022-06-11 12:09:20 +03:00
|
|
|
|
Material for MkDocs supports two color schemes: a __light mode__, which is just
|
|
|
|
|
called `default`, and a __dark mode__, which is called `slate`. The color scheme
|
2020-07-23 14:17:50 +03:00
|
|
|
|
can be set via `mkdocs.yml`:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
palette:
|
|
|
|
|
scheme: default
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
Click on a tile to change the color scheme:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2021-02-24 20:02:09 +03:00
|
|
|
|
<div class="mdx-switch">
|
2020-07-19 23:23:26 +03:00
|
|
|
|
<button data-md-color-scheme="default"><code>default</code></button>
|
|
|
|
|
<button data-md-color-scheme="slate"><code>slate</code></button>
|
|
|
|
|
</div>
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
var buttons = document.querySelectorAll("button[data-md-color-scheme]")
|
|
|
|
|
buttons.forEach(function(button) {
|
|
|
|
|
button.addEventListener("click", function() {
|
2023-03-24 13:36:30 +03:00
|
|
|
|
document.body.setAttribute("data-md-color-switching", "")
|
2020-07-17 14:08:27 +03:00
|
|
|
|
var attr = this.getAttribute("data-md-color-scheme")
|
|
|
|
|
document.body.setAttribute("data-md-color-scheme", attr)
|
2023-03-19 19:30:34 +03:00
|
|
|
|
var name = document.querySelector("#__code_0 code span.l")
|
2020-07-17 14:08:27 +03:00
|
|
|
|
name.textContent = attr
|
2023-03-24 13:36:30 +03:00
|
|
|
|
setTimeout(function() {
|
|
|
|
|
document.body.removeAttribute("data-md-color-switching")
|
|
|
|
|
})
|
2020-07-16 23:31:39 +03:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2020-08-27 00:21:28 +03:00
|
|
|
|
#### Primary color
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:version 0.2.0 -->
|
|
|
|
|
<!-- md:default `indigo` -->
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
The primary color is used for the header, the sidebar, text links and several
|
2020-07-16 23:31:39 +03:00
|
|
|
|
other components. In order to change the primary color, set the following value
|
|
|
|
|
in `mkdocs.yml` to a valid color name:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
palette:
|
|
|
|
|
primary: indigo
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
Click on a tile to change the primary color:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2021-02-24 20:02:09 +03:00
|
|
|
|
<div class="mdx-switch">
|
2020-07-19 23:23:26 +03:00
|
|
|
|
<button data-md-color-primary="red"><code>red</code></button>
|
|
|
|
|
<button data-md-color-primary="pink"><code>pink</code></button>
|
|
|
|
|
<button data-md-color-primary="purple"><code>purple</code></button>
|
|
|
|
|
<button data-md-color-primary="deep-purple"><code>deep purple</code></button>
|
|
|
|
|
<button data-md-color-primary="indigo"><code>indigo</code></button>
|
|
|
|
|
<button data-md-color-primary="blue"><code>blue</code></button>
|
|
|
|
|
<button data-md-color-primary="light-blue"><code>light blue</code></button>
|
|
|
|
|
<button data-md-color-primary="cyan"><code>cyan</code></button>
|
|
|
|
|
<button data-md-color-primary="teal"><code>teal</code></button>
|
|
|
|
|
<button data-md-color-primary="green"><code>green</code></button>
|
|
|
|
|
<button data-md-color-primary="light-green"><code>light green</code></button>
|
|
|
|
|
<button data-md-color-primary="lime"><code>lime</code></button>
|
|
|
|
|
<button data-md-color-primary="yellow"><code>yellow</code></button>
|
|
|
|
|
<button data-md-color-primary="amber"><code>amber</code></button>
|
|
|
|
|
<button data-md-color-primary="orange"><code>orange</code></button>
|
|
|
|
|
<button data-md-color-primary="deep-orange"><code>deep orange</code></button>
|
|
|
|
|
<button data-md-color-primary="brown"><code>brown</code></button>
|
|
|
|
|
<button data-md-color-primary="grey"><code>grey</code></button>
|
|
|
|
|
<button data-md-color-primary="blue-grey"><code>blue grey</code></button>
|
|
|
|
|
<button data-md-color-primary="black"><code>black</code></button>
|
|
|
|
|
<button data-md-color-primary="white"><code>white</code></button>
|
|
|
|
|
</div>
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
var buttons = document.querySelectorAll("button[data-md-color-primary]")
|
|
|
|
|
buttons.forEach(function(button) {
|
|
|
|
|
button.addEventListener("click", function() {
|
2020-07-17 14:08:27 +03:00
|
|
|
|
var attr = this.getAttribute("data-md-color-primary")
|
|
|
|
|
document.body.setAttribute("data-md-color-primary", attr)
|
2023-03-19 19:30:34 +03:00
|
|
|
|
var name = document.querySelector("#__code_1 code span.l")
|
2020-07-17 14:08:27 +03:00
|
|
|
|
name.textContent = attr.replace("-", " ")
|
2020-07-16 23:31:39 +03:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2023-04-28 13:57:37 +03:00
|
|
|
|
See our guide below to learn how to set [custom colors].
|
|
|
|
|
|
2020-08-27 00:21:28 +03:00
|
|
|
|
#### Accent color
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:version 0.2.0 -->
|
|
|
|
|
<!-- md:default `indigo` -->
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
The accent color is used to denote elements that can be interacted with, e.g.
|
2020-07-16 23:31:39 +03:00
|
|
|
|
hovered links, buttons and scrollbars. It can be changed in `mkdocs.yml` by
|
2020-07-26 15:46:09 +03:00
|
|
|
|
choosing a valid color name:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
palette:
|
|
|
|
|
accent: indigo
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
Click on a tile to change the accent color:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.md-typeset button[data-md-color-accent] > code {
|
2020-07-19 23:23:26 +03:00
|
|
|
|
background-color: var(--md-code-bg-color);
|
2020-07-16 23:31:39 +03:00
|
|
|
|
color: var(--md-accent-fg-color);
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
2021-02-24 20:02:09 +03:00
|
|
|
|
<div class="mdx-switch">
|
2020-07-19 23:23:26 +03:00
|
|
|
|
<button data-md-color-accent="red"><code>red</code></button>
|
|
|
|
|
<button data-md-color-accent="pink"><code>pink</code></button>
|
|
|
|
|
<button data-md-color-accent="purple"><code>purple</code></button>
|
|
|
|
|
<button data-md-color-accent="deep-purple"><code>deep purple</code></button>
|
|
|
|
|
<button data-md-color-accent="indigo"><code>indigo</code></button>
|
|
|
|
|
<button data-md-color-accent="blue"><code>blue</code></button>
|
|
|
|
|
<button data-md-color-accent="light-blue"><code>light blue</code></button>
|
|
|
|
|
<button data-md-color-accent="cyan"><code>cyan</code></button>
|
|
|
|
|
<button data-md-color-accent="teal"><code>teal</code></button>
|
|
|
|
|
<button data-md-color-accent="green"><code>green</code></button>
|
|
|
|
|
<button data-md-color-accent="light-green"><code>light green</code></button>
|
|
|
|
|
<button data-md-color-accent="lime"><code>lime</code></button>
|
|
|
|
|
<button data-md-color-accent="yellow"><code>yellow</code></button>
|
|
|
|
|
<button data-md-color-accent="amber"><code>amber</code></button>
|
|
|
|
|
<button data-md-color-accent="orange"><code>orange</code></button>
|
|
|
|
|
<button data-md-color-accent="deep-orange"><code>deep orange</code></button>
|
|
|
|
|
</div>
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
var buttons = document.querySelectorAll("button[data-md-color-accent]")
|
|
|
|
|
buttons.forEach(function(button) {
|
|
|
|
|
button.addEventListener("click", function() {
|
2020-07-17 14:08:27 +03:00
|
|
|
|
var attr = this.getAttribute("data-md-color-accent")
|
|
|
|
|
document.body.setAttribute("data-md-color-accent", attr)
|
2023-03-19 19:30:34 +03:00
|
|
|
|
var name = document.querySelector("#__code_2 code span.l")
|
2020-07-17 14:08:27 +03:00
|
|
|
|
name.textContent = attr.replace("-", " ")
|
2020-07-16 23:31:39 +03:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
2023-04-28 13:57:37 +03:00
|
|
|
|
See our guide below to learn how to set [custom colors].
|
|
|
|
|
|
2020-08-27 00:21:28 +03:00
|
|
|
|
### Color palette toggle
|
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:version 7.1.0 -->
|
|
|
|
|
<!-- md:default none -->
|
2020-08-27 00:21:28 +03:00
|
|
|
|
|
2022-06-11 12:09:20 +03:00
|
|
|
|
Offering a light _and_ dark color palette makes your documentation pleasant to
|
|
|
|
|
read at different times of the day, so the user can choose accordingly. Add the
|
|
|
|
|
following lines to `mkdocs.yml`:
|
2021-04-18 17:19:39 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
``` yaml
|
2020-08-27 00:21:28 +03:00
|
|
|
|
theme:
|
2021-12-11 16:30:07 +03:00
|
|
|
|
palette: # (1)!
|
2022-06-11 12:09:20 +03:00
|
|
|
|
|
|
|
|
|
# Palette toggle for light mode
|
2021-04-18 17:19:39 +03:00
|
|
|
|
- scheme: default
|
2020-08-27 00:21:28 +03:00
|
|
|
|
toggle:
|
2022-06-11 12:09:20 +03:00
|
|
|
|
icon: material/brightness-7 # (2)!
|
2021-02-24 20:59:12 +03:00
|
|
|
|
name: Switch to dark mode
|
2022-06-11 12:09:20 +03:00
|
|
|
|
|
|
|
|
|
# Palette toggle for dark mode
|
2022-06-14 10:32:39 +03:00
|
|
|
|
- scheme: slate
|
2020-08-27 00:21:28 +03:00
|
|
|
|
toggle:
|
2022-06-11 12:09:20 +03:00
|
|
|
|
icon: material/brightness-4
|
2021-02-24 20:59:12 +03:00
|
|
|
|
name: Switch to light mode
|
2020-08-27 00:21:28 +03:00
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
1. Note that the `theme.palette` setting is now defined as a list.
|
2022-01-16 19:34:27 +03:00
|
|
|
|
|
|
|
|
|
2. Enter a few keywords to find the perfect icon using our [icon search] and
|
|
|
|
|
click on the shortcode to copy it to your clipboard:
|
|
|
|
|
|
|
|
|
|
<div class="mdx-iconsearch" data-mdx-component="iconsearch">
|
2022-06-11 12:09:20 +03:00
|
|
|
|
<input class="md-input md-input--stretch mdx-iconsearch__input" placeholder="Search icon" data-mdx-component="iconsearch-query" value="brightness" />
|
2022-01-16 19:34:27 +03:00
|
|
|
|
<div class="mdx-iconsearch-result" data-mdx-component="iconsearch-result" data-mdx-mode="file">
|
|
|
|
|
<div class="mdx-iconsearch-result__meta"></div>
|
|
|
|
|
<ol class="mdx-iconsearch-result__list"></ol>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-06-11 12:09:20 +03:00
|
|
|
|
This configuration will render a color palette toggle next to the search bar.
|
2022-06-14 10:32:39 +03:00
|
|
|
|
Note that you can also define separate settings for [`primary`][palette.primary]
|
|
|
|
|
and [`accent`][palette.accent] per color palette.
|
2022-06-11 12:09:20 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
The following properties must be set for each toggle:
|
2020-08-27 00:21:28 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:option palette.toggle.icon -->
|
2020-08-27 00:21:28 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
: <!-- md:default none --> <!-- md:flag required -->
|
2022-01-16 21:45:40 +03:00
|
|
|
|
This property must point to a valid icon path referencing any icon bundled
|
|
|
|
|
with the theme, or the build will not succeed. Some popular combinations:
|
2020-08-27 00:21:28 +03:00
|
|
|
|
|
2022-06-11 12:09:20 +03:00
|
|
|
|
* :material-brightness-7: + :material-brightness-4: – `material/brightness-7` + `material/brightness-4`
|
2022-05-08 18:50:57 +03:00
|
|
|
|
* :material-toggle-switch: + :material-toggle-switch-off-outline: – `material/toggle-switch` + `material/toggle-switch-off-outline`
|
|
|
|
|
* :material-weather-night: + :material-weather-sunny: – `material/weather-night` + `material/weather-sunny`
|
|
|
|
|
* :material-eye: + :material-eye-outline: – `material/eye` + `material/eye-outline`
|
|
|
|
|
* :material-lightbulb: + :material-lightbulb-outline: – `material/lightbulb` + `material/lightbulb-outline`
|
2020-08-27 00:21:28 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:option palette.toggle.name -->
|
2020-08-27 00:21:28 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
: <!-- md:default none --> <!-- md:flag required -->
|
2022-06-11 12:09:20 +03:00
|
|
|
|
This property is used as the toggle's `title` attribute and should be set to
|
|
|
|
|
a discernable name to improve accessibility. It's rendered as a [tooltip].
|
2020-08-27 00:21:28 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
[palette.scheme]: #color-scheme
|
|
|
|
|
[palette.primary]: #primary-color
|
|
|
|
|
[palette.accent]: #accent-color
|
2022-01-16 21:45:40 +03:00
|
|
|
|
[icon search]: ../reference/icons-emojis.md#search
|
2022-06-11 12:09:20 +03:00
|
|
|
|
[tooltip]: ../reference/tooltips.md
|
2021-04-18 17:19:39 +03:00
|
|
|
|
|
|
|
|
|
### System preference
|
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:version 7.1.0 -->
|
|
|
|
|
<!-- md:default none -->
|
2021-04-18 17:19:39 +03:00
|
|
|
|
|
2022-06-11 12:09:20 +03:00
|
|
|
|
Each color palette can be linked to the user's system preference for light and
|
|
|
|
|
dark appearance by using a media query. Simply add a `media` property next to
|
|
|
|
|
the `scheme` definition in `mkdocs.yml`:
|
2021-04-18 17:19:39 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
``` yaml
|
2021-04-18 17:19:39 +03:00
|
|
|
|
theme:
|
|
|
|
|
palette:
|
2022-06-11 12:09:20 +03:00
|
|
|
|
|
|
|
|
|
# Palette toggle for light mode
|
|
|
|
|
- media: "(prefers-color-scheme: light)"
|
2021-04-18 17:19:39 +03:00
|
|
|
|
scheme: default
|
|
|
|
|
toggle:
|
2022-06-11 12:09:20 +03:00
|
|
|
|
icon: material/brightness-7
|
2021-04-18 17:19:39 +03:00
|
|
|
|
name: Switch to dark mode
|
2022-06-11 12:09:20 +03:00
|
|
|
|
|
|
|
|
|
# Palette toggle for dark mode
|
|
|
|
|
- media: "(prefers-color-scheme: dark)"
|
2021-04-18 17:19:39 +03:00
|
|
|
|
scheme: slate
|
|
|
|
|
toggle:
|
2022-06-11 12:09:20 +03:00
|
|
|
|
icon: material/brightness-4
|
2021-04-18 17:19:39 +03:00
|
|
|
|
name: Switch to light mode
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
When the user first visits your site, the media queries are evaluated in the
|
|
|
|
|
order of their definition. The first media query that matches selects the
|
|
|
|
|
default color palette.
|
|
|
|
|
|
2022-07-17 16:20:08 +03:00
|
|
|
|
#### Automatic light / dark mode
|
2022-06-11 12:09:20 +03:00
|
|
|
|
|
2023-09-14 20:09:18 +03:00
|
|
|
|
<!-- md:sponsors -->
|
|
|
|
|
<!-- md:version insiders-4.18.0 -->
|
|
|
|
|
<!-- md:flag experimental -->
|
2022-06-11 12:09:20 +03:00
|
|
|
|
|
|
|
|
|
Newer operating system allow to automatically switch between light and dark
|
|
|
|
|
appearance during day and night times. [Insiders] adds support for automatic
|
2022-06-11 12:41:50 +03:00
|
|
|
|
light / dark mode, delegating color palette selection to the user's operating
|
2022-06-11 12:09:20 +03:00
|
|
|
|
system. Add the following lines to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
palette:
|
|
|
|
|
|
|
|
|
|
# Palette toggle for automatic mode
|
|
|
|
|
- media: "(prefers-color-scheme)"
|
|
|
|
|
toggle:
|
|
|
|
|
icon: material/brightness-auto
|
|
|
|
|
name: Switch to light mode
|
|
|
|
|
|
|
|
|
|
# Palette toggle for light mode
|
|
|
|
|
- media: "(prefers-color-scheme: light)"
|
2022-07-17 16:20:08 +03:00
|
|
|
|
scheme: default # (1)!
|
2022-06-11 12:09:20 +03:00
|
|
|
|
toggle:
|
|
|
|
|
icon: material/brightness-7
|
|
|
|
|
name: Switch to dark mode
|
|
|
|
|
|
|
|
|
|
# Palette toggle for dark mode
|
|
|
|
|
- media: "(prefers-color-scheme: dark)"
|
|
|
|
|
scheme: slate
|
|
|
|
|
toggle:
|
|
|
|
|
icon: material/brightness-4
|
|
|
|
|
name: Switch to system preference
|
|
|
|
|
```
|
|
|
|
|
|
2022-06-14 10:32:39 +03:00
|
|
|
|
1. You can also define separate settings for [`primary`][palette.primary] and
|
|
|
|
|
[`accent`][palette.accent] per color palette, i.e. different colors for
|
|
|
|
|
light and dark mode.
|
|
|
|
|
|
2022-06-11 12:09:20 +03:00
|
|
|
|
Material for MkDocs will now change the color palette each time the operating
|
|
|
|
|
system switches between light and dark appearance, even when the user doesn't
|
|
|
|
|
reload the site.
|
|
|
|
|
|
|
|
|
|
[Insiders]: ../insiders/index.md
|
|
|
|
|
|
2020-07-16 23:31:39 +03:00
|
|
|
|
## Customization
|
|
|
|
|
|
2020-07-21 19:39:27 +03:00
|
|
|
|
### Custom colors
|
2020-07-21 17:01:22 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
Material for MkDocs implements colors using [CSS variables] (custom
|
2020-07-16 23:31:39 +03:00
|
|
|
|
properties). If you want to customize the colors beyond the palette (e.g. to
|
2021-10-10 18:39:53 +03:00
|
|
|
|
use your brand-specific colors), you can add an [additional style sheet] and
|
2020-07-23 14:17:50 +03:00
|
|
|
|
tweak the values of the CSS variables.
|
|
|
|
|
|
2023-04-28 13:57:37 +03:00
|
|
|
|
First, set the [`primary`][palette.primary] or [`accent`][palette.accent] values
|
|
|
|
|
in `mkdocs.yml` to `custom`, to signal to the theme that you want to define
|
|
|
|
|
custom colors, e.g., when you want to override the `primary` color:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
palette:
|
|
|
|
|
primary: custom
|
|
|
|
|
```
|
|
|
|
|
|
2021-03-13 16:30:29 +03:00
|
|
|
|
Let's say you're :fontawesome-brands-youtube:{ style="color: #EE0F0F" }
|
2020-07-24 15:30:03 +03:00
|
|
|
|
__YouTube__, and want to set the primary color to your brand's palette. Just
|
2020-07-23 14:17:50 +03:00
|
|
|
|
add:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
=== ":octicons-file-code-16: `docs/stylesheets/extra.css`"
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
``` css
|
2022-12-15 00:15:05 +03:00
|
|
|
|
:root {
|
2021-10-10 18:39:53 +03:00
|
|
|
|
--md-primary-fg-color: #EE0F0F;
|
|
|
|
|
--md-primary-fg-color--light: #ECB7B7;
|
|
|
|
|
--md-primary-fg-color--dark: #90030C;
|
|
|
|
|
}
|
|
|
|
|
```
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
=== ":octicons-file-code-16: `mkdocs.yml`"
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
``` yaml
|
|
|
|
|
extra_css:
|
|
|
|
|
- stylesheets/extra.css
|
|
|
|
|
```
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
See the file containing the [color definitions] for a list of all CSS variables.
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
[CSS variables]: https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties
|
2023-09-20 15:03:28 +03:00
|
|
|
|
[color definitions]: https://github.com/squidfunk/mkdocs-material/blob/master/src/templates/assets/stylesheets/main/_colors.scss
|
2021-10-10 18:39:53 +03:00
|
|
|
|
[additional style sheet]: ../customization.md#additional-css
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Custom color schemes
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
|
|
|
|
Besides overriding specific colors, you can create your own, named color scheme
|
2021-10-10 18:39:53 +03:00
|
|
|
|
by wrapping the definitions in a `[data-md-color-scheme="..."]`
|
|
|
|
|
[attribute selector], which you can then set via `mkdocs.yml` as described
|
|
|
|
|
in the [color schemes][palette.scheme] section:
|
2020-07-16 23:31:39 +03:00
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
=== ":octicons-file-code-16: `docs/stylesheets/extra.css`"
|
2021-10-10 18:39:53 +03:00
|
|
|
|
|
|
|
|
|
``` css
|
|
|
|
|
[data-md-color-scheme="youtube"] {
|
|
|
|
|
--md-primary-fg-color: #EE0F0F;
|
|
|
|
|
--md-primary-fg-color--light: #ECB7B7;
|
|
|
|
|
--md-primary-fg-color--dark: #90030C;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
=== ":octicons-file-code-16: `mkdocs.yml`"
|
2021-10-10 18:39:53 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
2021-10-10 20:22:13 +03:00
|
|
|
|
theme:
|
|
|
|
|
palette:
|
|
|
|
|
scheme: youtube
|
2021-10-10 18:39:53 +03:00
|
|
|
|
extra_css:
|
|
|
|
|
- stylesheets/extra.css
|
|
|
|
|
```
|
2020-07-27 15:44:47 +03:00
|
|
|
|
|
|
|
|
|
Additionally, the `slate` color scheme defines all of it's colors via `hsla`
|
|
|
|
|
color functions and deduces its colors from the `--md-hue` CSS variable. You
|
|
|
|
|
can tune the `slate` theme with:
|
|
|
|
|
|
|
|
|
|
``` css
|
|
|
|
|
[data-md-color-scheme="slate"] {
|
2021-12-11 16:30:07 +03:00
|
|
|
|
--md-hue: 210; /* (1)! */
|
2020-07-27 15:44:47 +03:00
|
|
|
|
}
|
2020-07-16 23:31:39 +03:00
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 18:39:53 +03:00
|
|
|
|
1. The `hue` value must be in the range of `[0, 360]`
|
|
|
|
|
|
|
|
|
|
[attribute selector]: https://www.w3.org/TR/selectors-4/#attribute-selectors
|