2020-07-24 10:59:16 +03:00
|
|
|
|
---
|
|
|
|
|
template: overrides/main.html
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Icons + Emojis
|
|
|
|
|
|
|
|
|
|
One of the best features of Material for MkDocs is the possibility to use [more
|
2021-02-06 14:35:19 +03:00
|
|
|
|
than 8.000 icons][1] and thousands of emojis in your project documentation
|
2020-09-20 12:24:46 +03:00
|
|
|
|
with practically zero additional effort. Furthermore, custom icons can be added
|
|
|
|
|
and used in `mkdocs.yml`, documents and templates.
|
2020-07-24 10:59:16 +03:00
|
|
|
|
|
2021-02-06 14:35:19 +03:00
|
|
|
|
## Search
|
|
|
|
|
|
2021-02-14 16:51:08 +03:00
|
|
|
|
<div class="mdx-icon-search" data-mdx-component="icon-search">
|
|
|
|
|
<input
|
|
|
|
|
class="md-input md-input--stretch mdx-icon-search__input"
|
2021-02-15 17:57:44 +03:00
|
|
|
|
placeholder="Search the icon and emoji database"
|
2021-02-14 16:51:08 +03:00
|
|
|
|
data-mdx-component="icon-search-query"
|
|
|
|
|
/>
|
|
|
|
|
<div class="mdx-icon-search-result" data-mdx-component="icon-search-result">
|
|
|
|
|
<div class="mdx-icon-search-result__meta"></div>
|
|
|
|
|
<ol class="mdx-icon-search-result__list"></ol>
|
|
|
|
|
</div>
|
2021-02-06 14:35:19 +03:00
|
|
|
|
</div>
|
2021-02-14 16:51:08 +03:00
|
|
|
|
<small>
|
|
|
|
|
:octicons-light-bulb-16:
|
2021-02-15 17:57:44 +03:00
|
|
|
|
**Tip:** Enter some keywords to find the perfect icon or emoji and click on
|
|
|
|
|
the shortcode to copy it to your clipboard.
|
2021-02-14 16:51:08 +03:00
|
|
|
|
</small>
|
2021-02-06 14:35:19 +03:00
|
|
|
|
|
2020-07-24 10:59:16 +03:00
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
|
|
### Emoji
|
|
|
|
|
|
|
|
|
|
[:octicons-file-code-24: Source][2] · [:octicons-workflow-24: Extension][3]
|
|
|
|
|
|
|
|
|
|
The [Emoji][3] extension, which is part of [Python Markdown Extensions][4],
|
|
|
|
|
adds the ability to __integrate emojis and icons__ in the `*.svg` file format,
|
|
|
|
|
which are inlined when [building your site][5]:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- pymdownx.emoji:
|
|
|
|
|
emoji_index: !!python/name:materialx.emoji.twemoji
|
|
|
|
|
emoji_generator: !!python/name:materialx.emoji.to_svg
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The following icon sets are bundled with Material for MkDocs:
|
|
|
|
|
|
2020-11-16 00:25:11 +03:00
|
|
|
|
- :material-material-design: – [Material Design][6]
|
|
|
|
|
- :fontawesome-brands-font-awesome-flag: – [FontAwesome][7]
|
|
|
|
|
- :octicons-mark-github-16: – [Octicons][8]
|
2020-07-24 10:59:16 +03:00
|
|
|
|
|
|
|
|
|
You can also add [additional icons][9]. When using emojis, it's recommended to
|
|
|
|
|
consult the official documentation of [Python Markdown Extensions][3] to learn
|
|
|
|
|
about configuration options.
|
|
|
|
|
|
2021-02-15 19:05:29 +03:00
|
|
|
|
[1]: icons-emojis.md#search
|
2020-07-24 10:59:16 +03:00
|
|
|
|
[2]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/extensions/pymdownx/_emoji.scss
|
|
|
|
|
[3]: https://facelessuser.github.io/pymdown-extensions/extensions/emoji/
|
|
|
|
|
[4]: https://facelessuser.github.io/pymdown-extensions/
|
|
|
|
|
[5]: ../creating-your-site.md#building-your-site
|
|
|
|
|
[6]: https://materialdesignicons.com/
|
|
|
|
|
[7]: https://fontawesome.com/icons?d=gallery&m=free
|
|
|
|
|
[8]: https://octicons.github.com/
|
|
|
|
|
[9]: ../setup/changing-the-logo-and-icons.md#additional-icons
|
|
|
|
|
|
2020-07-26 18:06:57 +03:00
|
|
|
|
### Attribute List
|
2020-07-26 15:46:09 +03:00
|
|
|
|
|
|
|
|
|
The [Attribute List][10] extension, which is part of the standard Markdown
|
2020-07-27 13:05:07 +03:00
|
|
|
|
library, allows to __add HTML attributes and CSS classes to Markdown elements__,
|
2020-07-26 15:46:09 +03:00
|
|
|
|
and can be enabled via `mkdocs.yml`
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- attr_list
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
[10]: https://python-markdown.github.io/extensions/attr_list/
|
|
|
|
|
|
2020-07-24 10:59:16 +03:00
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
### Using emojis
|
|
|
|
|
|
|
|
|
|
Emojis can be integrated in Markdown by putting the shortcode of the emoji
|
2020-07-26 15:46:09 +03:00
|
|
|
|
between two colons. If you're using [Twemoji][11] (recommended), you can look up
|
|
|
|
|
the shortcodes at [Emojipedia][12].
|
2020-07-24 10:59:16 +03:00
|
|
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
:smile:
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
|
|
|
|
|
:smile:
|
|
|
|
|
|
2020-07-26 15:46:09 +03:00
|
|
|
|
[11]: https://twemoji.twitter.com/
|
|
|
|
|
[12]: https://emojipedia.org/twitter/
|
2020-07-24 10:59:16 +03:00
|
|
|
|
|
|
|
|
|
### Using icons
|
|
|
|
|
|
2020-07-26 15:46:09 +03:00
|
|
|
|
When [Emoji][13] is enabled, icons can be used similar to emojis, by referencing
|
2020-07-24 10:59:16 +03:00
|
|
|
|
a valid path to any icon bundled with the theme, which are located in the
|
|
|
|
|
[`.icons`][1] directory, and replacing `/` with `-`:
|
|
|
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
|
|
```
|
2020-11-16 00:25:11 +03:00
|
|
|
|
- :material-account-circle: – `.icons/material/account-circle.svg`
|
|
|
|
|
- :fontawesome-regular-laugh-wink: – `.icons/fontawesome/regular/laugh-wink.svg`
|
2020-12-21 19:38:58 +03:00
|
|
|
|
- :octicons-octoface-24: – `.icons/octicons/octoface-24.svg`
|
2020-07-24 10:59:16 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
|
2020-11-16 00:25:11 +03:00
|
|
|
|
- :material-account-circle: – [`.icons/material/account-circle.svg`][14]
|
|
|
|
|
- :fontawesome-regular-laugh-wink: – [`.icons/fontawesome/regular/laugh-wink.svg`][15]
|
2020-12-21 19:38:58 +03:00
|
|
|
|
- :octicons-octoface-24: – [`.icons/octicons/octoface-24.svg`][16]
|
2020-07-26 15:46:09 +03:00
|
|
|
|
|
|
|
|
|
[13]: #emoji
|
|
|
|
|
[14]: https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/material/.icons/material/account-circle.svg
|
|
|
|
|
[15]: https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/material/.icons/fontawesome/regular/laugh-wink.svg
|
2020-12-21 19:38:58 +03:00
|
|
|
|
[16]: https://raw.githubusercontent.com/squidfunk/mkdocs-material/master/material/.icons/octicons/octoface-24.svg
|
2020-07-26 15:46:09 +03:00
|
|
|
|
|
2020-07-26 18:06:57 +03:00
|
|
|
|
#### with colors
|
|
|
|
|
|
|
|
|
|
When the [Attribute List][17] extension is enabled, custom CSS classes and
|
|
|
|
|
attributes can be added to icons by suffixing the icon with a special syntax.
|
|
|
|
|
While HTML and CSS allow to use [inline styles][18], it's always best to add
|
|
|
|
|
an [additional stylesheet][19] and put styles into dedicated CSS classes:
|
|
|
|
|
|
|
|
|
|
``` css
|
|
|
|
|
.medium {
|
|
|
|
|
color: #00AB6C;
|
|
|
|
|
}
|
|
|
|
|
.twitter {
|
|
|
|
|
color: #1DA1F2;
|
|
|
|
|
}
|
|
|
|
|
.facebook {
|
|
|
|
|
color: #4267B2;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-03 00:15:19 +03:00
|
|
|
|
Then, simply add the CSS class to the icon.
|
2020-07-26 18:06:57 +03:00
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.medium {
|
|
|
|
|
color: #00AB6C;
|
|
|
|
|
}
|
|
|
|
|
.twitter {
|
|
|
|
|
color: #1DA1F2;
|
|
|
|
|
}
|
|
|
|
|
.facebook {
|
|
|
|
|
color: #4267B2;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
|
|
``` markdown
|
2020-11-16 00:25:11 +03:00
|
|
|
|
- :fontawesome-brands-medium:{: .medium } – Medium
|
|
|
|
|
- :fontawesome-brands-twitter:{: .twitter } – Twitter
|
|
|
|
|
- :fontawesome-brands-facebook:{: .facebook } – Facebook
|
2020-07-26 18:06:57 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
|
2020-11-16 00:25:11 +03:00
|
|
|
|
- :fontawesome-brands-medium:{: .medium } – Medium
|
|
|
|
|
- :fontawesome-brands-twitter:{: .twitter } – Twitter
|
|
|
|
|
- :fontawesome-brands-facebook:{: .facebook } – Facebook
|
2020-07-26 18:06:57 +03:00
|
|
|
|
|
|
|
|
|
[17]: #attribute-list
|
|
|
|
|
[18]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/style
|
2020-09-19 15:34:40 +03:00
|
|
|
|
[19]: ../customization.md#additional-css
|
2020-07-26 18:06:57 +03:00
|
|
|
|
|
|
|
|
|
#### with animations
|
|
|
|
|
|
|
|
|
|
Similar to adding [colors][20], it's just as easy to add [CSS animations][21] to
|
|
|
|
|
icons by using an [additional stylesheet][6], defining a `#!css @keyframes` rule
|
|
|
|
|
and adding the dedicated CSS class to the icon:
|
|
|
|
|
|
|
|
|
|
``` css
|
|
|
|
|
@keyframes heart {
|
|
|
|
|
0%, 40%, 80%, 100% {
|
|
|
|
|
transform: scale(1);
|
|
|
|
|
}
|
|
|
|
|
20%, 60% {
|
|
|
|
|
transform: scale(1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.heart {
|
|
|
|
|
animation: heart 1000ms infinite;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-03 00:15:19 +03:00
|
|
|
|
Then, simply add the CSS class to the icon.
|
2020-07-26 18:06:57 +03:00
|
|
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
|
|
``` markdown
|
|
|
|
|
:octicons-heart-fill-24:{: .heart }
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
|
2020-12-21 19:38:58 +03:00
|
|
|
|
:octicons-heart-fill-24:{: .tx-heart }
|
2020-07-24 10:59:16 +03:00
|
|
|
|
|
2020-07-26 18:06:57 +03:00
|
|
|
|
[20]: #with-colors
|
|
|
|
|
[21]: https://developer.mozilla.org/en-US/docs/Web/CSS/animation
|
2020-07-30 21:36:08 +03:00
|
|
|
|
|
|
|
|
|
## Customization
|
|
|
|
|
|
|
|
|
|
### Using icons in templates
|
|
|
|
|
|
|
|
|
|
When you're [extending the theme][22] with partials or blocks, you can simply
|
|
|
|
|
reference any icon that's [bundled with the theme][1] with Jinja's
|
|
|
|
|
[`include`][23] function and wrap it with the `twemoji` class:
|
|
|
|
|
|
|
|
|
|
``` html
|
|
|
|
|
<span class="twemoji">
|
|
|
|
|
{% include ".icons/fontawesome/brands/twitter.svg" %}
|
|
|
|
|
</span>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This is exactly what Material for MkDocs does in its templates.
|
|
|
|
|
|
|
|
|
|
[22]: ../customization.md#extending-the-theme
|
|
|
|
|
[23]: https://jinja.palletsprojects.com/en/2.11.x/templates/#include
|