Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit b657fb7

Browse files
authored
Merge pull request #1 from mkdocs-material/docs/add-more-examples
New examples for colors
2 parents 6247988 + e8aa17a commit b657fb7

File tree

24 files changed

+437
-34
lines changed

24 files changed

+437
-34
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Examples
22

3-
- [Tags]
4-
- [Tags with icons]
3+
This repository contains runnable examples for [Material for MkDocs].
54

6-
[Tags]: example/tags/
7-
[Tags with icons]: examples/tags-with-icons/
5+
[Material for MkDocs]: https://squidfunk.github.io/mkdocs-material/

examples/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,8 @@ def transform(project: MkDocsConfig, config: MkDocsConfig):
4545
project.copyright = config.copyright
4646

4747
# Inherit settings for theme
48-
merge(project.theme["icon"], config.theme["icon"])
4948
project.theme["features"].extend(config.theme["features"])
49+
if "icon" in project.theme:
50+
merge(project.theme["icon"], config.theme["icon"])
51+
else:
52+
project.theme["icon"] = config.theme["icon"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Using the color palette system preference
2+
3+
This example shows how to implement the [color palette toggle] so that it
4+
automatically uses the user's [system preference]. Click on the button left
5+
to the search bar to switch between modes.
6+
7+
[color palette toggle]: https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#color-palette-toggle
8+
[system preference]: https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#system-preference
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (c) 2016-2023 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
# -----------------------------------------------------------------------------
22+
# Recommended: set up configuration validation, see https://t.ly/xpZXU
23+
# -----------------------------------------------------------------------------
24+
25+
# Project information
26+
site_name: Using the color palette system preference
27+
28+
# Theme
29+
theme:
30+
name: material
31+
features:
32+
- navigation.sections
33+
palette:
34+
- media: "(prefers-color-scheme)"
35+
toggle:
36+
icon: material/brightness-auto
37+
name: Switch to light mode
38+
- media: "(prefers-color-scheme: light)"
39+
scheme: default
40+
primary: indigo
41+
accent: indigo
42+
toggle:
43+
icon: material/brightness-7
44+
name: Switch to dark mode
45+
- media: "(prefers-color-scheme: dark)"
46+
scheme: slate
47+
primary: indigo
48+
accent: indigo
49+
toggle:
50+
icon: material/brightness-4
51+
name: Switch to system preference
52+
53+
# Markdown extensions
54+
markdown_extensions:
55+
- attr_list
56+
- toc:
57+
permalink: true
58+
- pymdownx.highlight
59+
- pymdownx.superfences
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2016-2023 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
mkdocs-material
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Using the color palette toggle
2+
3+
This example shows how to implement the [color palette toggle] to let users switch
4+
between light and dark mode. Click on the button left to the search bar to
5+
switch between modes.
6+
7+
[color palette toggle]: https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#color-palette-toggle
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright (c) 2016-2023 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
# -----------------------------------------------------------------------------
22+
# Recommended: set up configuration validation, see https://t.ly/xpZXU
23+
# -----------------------------------------------------------------------------
24+
25+
# Project information
26+
site_name: Using the color palette toggle
27+
28+
# Theme
29+
theme:
30+
name: material
31+
features:
32+
- navigation.sections
33+
palette:
34+
- scheme: default
35+
primary: indigo
36+
accent: indigo
37+
toggle:
38+
icon: material/brightness-7
39+
name: Switch to dark mode
40+
- scheme: slate
41+
primary: indigo
42+
accent: indigo
43+
toggle:
44+
icon: material/brightness-4
45+
name: Switch to light mode
46+
47+
# Markdown extensions
48+
markdown_extensions:
49+
- attr_list
50+
- toc:
51+
permalink: true
52+
- pymdownx.highlight
53+
- pymdownx.superfences
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2016-2023 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
mkdocs-material
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Overview
3+
---
4+
5+
# Adding a cookie consent
6+
7+
This example shows how to add a [cookie consent]. [Click here] to bring
8+
up the cookie consent again.
9+
10+
[cookie consent]: https://squidfunk.github.io/mkdocs-material/setup/ensuring-data-privacy/#cookie-consent
11+
[Click here]: #__consent

examples/cookie-consent/mkdocs.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) 2016-2023 Martin Donath <[email protected]>
2+
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to
5+
# deal in the Software without restriction, including without limitation the
6+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
# sell copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
# IN THE SOFTWARE.
20+
21+
# -----------------------------------------------------------------------------
22+
# Recommended: set up configuration validation, see https://t.ly/xpZXU
23+
# -----------------------------------------------------------------------------
24+
25+
# Project information
26+
site_name: Adding a cookie consent
27+
28+
# Theme
29+
theme:
30+
name: material
31+
features:
32+
- navigation.sections
33+
34+
# Additional configuration
35+
extra:
36+
consent:
37+
title: Cookie consent
38+
description: >-
39+
We use cookies to recognize your repeated visits and preferences, as well
40+
as to measure the effectiveness of our documentation and whether users
41+
find what they're searching for. With your consent, you're helping us to
42+
make our documentation better.
43+
44+
# Markdown extensions
45+
markdown_extensions:
46+
- attr_list
47+
- toc:
48+
permalink: true
49+
- pymdownx.highlight
50+
- pymdownx.superfences

0 commit comments

Comments
 (0)