Skip to content

Commit 584c313

Browse files
committed
Added documentation for custom admonitions
1 parent acd7422 commit 584c313

File tree

8 files changed

+82
-9
lines changed

8 files changed

+82
-9
lines changed

docs/reference/admonitions.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,76 @@ the default type, and thus fallback for unknown type qualifiers, is `note`:
325325
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et
326326
euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo
327327
purus auctor massa, nec semper lorem quam in massa.
328+
329+
## Customization
330+
331+
### Custom admonitions
332+
333+
If you want to add a custom admonition type, all you need is a color and an
334+
`svg` icon. Copy the icon's `svg` code from the [`.icons`][9] folder and add the
335+
following CSS to an [additional stylesheet][10]:
336+
337+
``` css
338+
:root {
339+
--md-admonition-icon--pied-piper: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M244 246c-3.2-2-6.3-2.9-10.1-2.9-6.6 0-12.6 3.2-19.3 3.7l1.7 4.9zm135.9 197.9c-19 0-64.1 9.5-79.9 19.8l6.9 45.1c35.7 6.1 70.1 3.6 106-9.8-4.8-10-23.5-55.1-33-55.1zM340.8 177c6.6 2.8 11.5 9.2 22.7 22.1 2-1.4 7.5-5.2 7.5-8.6 0-4.9-11.8-13.2-13.2-23 11.2-5.7 25.2-6 37.6-8.9 68.1-16.4 116.3-52.9 146.8-116.7C548.3 29.3 554 16.1 554.6 2l-2 2.6c-28.4 50-33 63.2-81.3 100-31.9 24.4-69.2 40.2-106.6 54.6l-6.3-.3v-21.8c-19.6 1.6-19.7-14.6-31.6-23-18.7 20.6-31.6 40.8-58.9 51.1-12.7 4.8-19.6 10-25.9 21.8 34.9-16.4 91.2-13.5 98.8-10zM555.5 0l-.6 1.1-.3.9.6-.6zm-59.2 382.1c-33.9-56.9-75.3-118.4-150-115.5l-.3-6c-1.1-13.5 32.8 3.2 35.1-31l-14.4 7.2c-19.8-45.7-8.6-54.3-65.5-54.3-14.7 0-26.7 1.7-41.4 4.6 2.9 18.6 2.2 36.7-10.9 50.3l19.5 5.5c-1.7 3.2-2.9 6.3-2.9 9.8 0 21 42.8 2.9 42.8 33.6 0 18.4-36.8 60.1-54.9 60.1-8 0-53.7-50-53.4-60.1l.3-4.6 52.3-11.5c13-2.6 12.3-22.7-2.9-22.7-3.7 0-43.1 9.2-49.4 10.6-2-5.2-7.5-14.1-13.8-14.1-3.2 0-6.3 3.2-9.5 4-9.2 2.6-31 2.9-21.5 20.1L15.9 298.5c-5.5 1.1-8.9 6.3-8.9 11.8 0 6 5.5 10.9 11.5 10.9 8 0 131.3-28.4 147.4-32.2 2.6 3.2 4.6 6.3 7.8 8.6 20.1 14.4 59.8 85.9 76.4 85.9 24.1 0 58-22.4 71.3-41.9 3.2-4.3 6.9-7.5 12.4-6.9.6 13.8-31.6 34.2-33 43.7-1.4 10.2-1 35.2-.3 41.1 26.7 8.1 52-3.6 77.9-2.9 4.3-21 10.6-41.9 9.8-63.5l-.3-9.5c-1.4-34.2-10.9-38.5-34.8-58.6-1.1-1.1-2.6-2.6-3.7-4 2.2-1.4 1.1-1 4.6-1.7 88.5 0 56.3 183.6 111.5 229.9 33.1-15 72.5-27.9 103.5-47.2-29-25.6-52.6-45.7-72.7-79.9zm-196.2 46.1v27.2l11.8-3.4-2.9-23.8zm-68.7-150.4l24.1 61.2 21-13.8-31.3-50.9zm84.4 154.9l2 12.4c9-1.5 58.4-6.6 58.4-14.1 0-1.4-.6-3.2-.9-4.6-26.8 0-36.9 3.8-59.5 6.3z"/></svg>')
340+
}
341+
.md-typeset .admonition.pied-piper,
342+
.md-typeset details.pied-piper {
343+
border-color: rgb(43, 155, 70);
344+
}
345+
.md-typeset .pied-piper > .admonition-title,
346+
.md-typeset .pied-piper > summary {
347+
background-color: rgba(43, 155, 70, 0.1);
348+
}
349+
.md-typeset .pied-piper > .admonition-title::before,
350+
.md-typeset .pied-piper > summary::before {
351+
background-color: rgb(43, 155, 70);
352+
-webkit-mask-image: var(--md-admonition-icon--pied-piper);
353+
mask-image: var(--md-admonition-icon--pied-piper);
354+
}
355+
```
356+
357+
You should now be able to create an admonition of the `pied-piper` type. Note
358+
that you can also use this technique to override existing admonition icons or
359+
colors. [You can even add animations][11].
360+
361+
<style>
362+
:root {
363+
--md-admonition-icon--pied-piper: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M244 246c-3.2-2-6.3-2.9-10.1-2.9-6.6 0-12.6 3.2-19.3 3.7l1.7 4.9zm135.9 197.9c-19 0-64.1 9.5-79.9 19.8l6.9 45.1c35.7 6.1 70.1 3.6 106-9.8-4.8-10-23.5-55.1-33-55.1zM340.8 177c6.6 2.8 11.5 9.2 22.7 22.1 2-1.4 7.5-5.2 7.5-8.6 0-4.9-11.8-13.2-13.2-23 11.2-5.7 25.2-6 37.6-8.9 68.1-16.4 116.3-52.9 146.8-116.7C548.3 29.3 554 16.1 554.6 2l-2 2.6c-28.4 50-33 63.2-81.3 100-31.9 24.4-69.2 40.2-106.6 54.6l-6.3-.3v-21.8c-19.6 1.6-19.7-14.6-31.6-23-18.7 20.6-31.6 40.8-58.9 51.1-12.7 4.8-19.6 10-25.9 21.8 34.9-16.4 91.2-13.5 98.8-10zM555.5 0l-.6 1.1-.3.9.6-.6zm-59.2 382.1c-33.9-56.9-75.3-118.4-150-115.5l-.3-6c-1.1-13.5 32.8 3.2 35.1-31l-14.4 7.2c-19.8-45.7-8.6-54.3-65.5-54.3-14.7 0-26.7 1.7-41.4 4.6 2.9 18.6 2.2 36.7-10.9 50.3l19.5 5.5c-1.7 3.2-2.9 6.3-2.9 9.8 0 21 42.8 2.9 42.8 33.6 0 18.4-36.8 60.1-54.9 60.1-8 0-53.7-50-53.4-60.1l.3-4.6 52.3-11.5c13-2.6 12.3-22.7-2.9-22.7-3.7 0-43.1 9.2-49.4 10.6-2-5.2-7.5-14.1-13.8-14.1-3.2 0-6.3 3.2-9.5 4-9.2 2.6-31 2.9-21.5 20.1L15.9 298.5c-5.5 1.1-8.9 6.3-8.9 11.8 0 6 5.5 10.9 11.5 10.9 8 0 131.3-28.4 147.4-32.2 2.6 3.2 4.6 6.3 7.8 8.6 20.1 14.4 59.8 85.9 76.4 85.9 24.1 0 58-22.4 71.3-41.9 3.2-4.3 6.9-7.5 12.4-6.9.6 13.8-31.6 34.2-33 43.7-1.4 10.2-1 35.2-.3 41.1 26.7 8.1 52-3.6 77.9-2.9 4.3-21 10.6-41.9 9.8-63.5l-.3-9.5c-1.4-34.2-10.9-38.5-34.8-58.6-1.1-1.1-2.6-2.6-3.7-4 2.2-1.4 1.1-1 4.6-1.7 88.5 0 56.3 183.6 111.5 229.9 33.1-15 72.5-27.9 103.5-47.2-29-25.6-52.6-45.7-72.7-79.9zm-196.2 46.1v27.2l11.8-3.4-2.9-23.8zm-68.7-150.4l24.1 61.2 21-13.8-31.3-50.9zm84.4 154.9l2 12.4c9-1.5 58.4-6.6 58.4-14.1 0-1.4-.6-3.2-.9-4.6-26.8 0-36.9 3.8-59.5 6.3z"/></svg>')
364+
}
365+
.md-typeset .admonition.pied-piper,
366+
.md-typeset details.pied-piper {
367+
border-color: rgb(43, 155, 70);
368+
}
369+
.md-typeset .pied-piper > .admonition-title,
370+
.md-typeset .pied-piper > summary {
371+
background-color: rgba(43, 155, 70, 0.1);
372+
}
373+
.md-typeset .pied-piper > .admonition-title::before,
374+
.md-typeset .pied-piper > summary::before {
375+
background-color: rgb(43, 155, 70);
376+
-webkit-mask-image: var(--md-admonition-icon--pied-piper);
377+
mask-image: var(--md-admonition-icon--pied-piper);
378+
}
379+
</style>
380+
381+
_Example_:
382+
383+
``` markdown
384+
!!! pied-piper "Pied Piper"
385+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
386+
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
387+
massa, nec semper lorem quam in massa.
388+
```
389+
390+
_Result_:
391+
392+
!!! pied-piper "Pied Piper"
393+
394+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
395+
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
396+
massa, nec semper lorem quam in massa.
397+
398+
[9]: https://github.com/squidfunk/mkdocs-material/tree/master/material/.icons
399+
[10]: ../customization.md#additional-stylesheets
400+
[11]: icons-emojis.md#with-animations

docs/reference/icons-emojis.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ an [additional stylesheet][19] and put styles into dedicated CSS classes:
124124
}
125125
```
126126

127-
Then, add the CSS classes to the icons:
127+
Then, simply add the CSS class to the icon.
128128

129129
<style>
130130
.medium {
@@ -177,7 +177,7 @@ and adding the dedicated CSS class to the icon:
177177
}
178178
```
179179

180-
Then, add the CSS class to the icon:
180+
Then, simply add the CSS class to the icon.
181181

182182
<style>
183183
@keyframes heart {

docs/reference/meta-tags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ tags to the template:
109109

110110
When you post links to your project documentation on [Twitter][9], it's
111111
highly recommended to add [Twitter's `meta` tags][10] to optimize the preview
112-
of your site:
112+
of your tweet:
113113

114114
``` html
115115
{% block extrahead %}

material/assets/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.82f1750e.min.js.map",
66
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.01088dc6.min.js",
77
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.01088dc6.min.js.map",
8-
"assets/stylesheets/main.css": "assets/stylesheets/main.155f8efd.min.css",
9-
"assets/stylesheets/main.css.map": "assets/stylesheets/main.155f8efd.min.css.map",
8+
"assets/stylesheets/main.css": "assets/stylesheets/main.256dd59f.min.css",
9+
"assets/stylesheets/main.css.map": "assets/stylesheets/main.256dd59f.min.css.map",
1010
"assets/stylesheets/overrides.css": "assets/stylesheets/overrides.76317e44.min.css",
1111
"assets/stylesheets/overrides.css.map": "assets/stylesheets/overrides.76317e44.min.css.map",
1212
"assets/stylesheets/palette.css": "assets/stylesheets/palette.88006c52.min.css",

material/assets/stylesheets/main.155f8efd.min.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

material/assets/stylesheets/main.155f8efd.min.css renamed to material/assets/stylesheets/main.256dd59f.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.256dd59f.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{% endif %}
4242
{% endblock %}
4343
{% block styles %}
44-
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.155f8efd.min.css' | url }}">
44+
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.256dd59f.min.css' | url }}">
4545
{% if palette.scheme or palette.primary or palette.accent %}
4646
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.88006c52.min.css' | url }}">
4747
{% endif %}

0 commit comments

Comments
 (0)