2020-07-27 13:32:24 +03:00
|
|
|
---
|
|
|
|
template: overrides/main.html
|
|
|
|
---
|
|
|
|
|
|
|
|
# Buttons
|
|
|
|
|
|
|
|
Material for MkDocs provides dedicated styles for primary and secondary buttons
|
|
|
|
that can be added to any link, `label` or `button` element. This is especially
|
|
|
|
useful for documents or landing pages with dedicated _call-to-actions_.
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
This configuration allows to add attributes to all inline- and block-level
|
|
|
|
elements with a simple syntax, turning any link into a button. Add the
|
|
|
|
following lines to `mkdocs.yml`:
|
2020-07-27 13:32:24 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
markdown_extensions:
|
|
|
|
- attr_list
|
|
|
|
```
|
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
See additional configuration options:
|
|
|
|
|
|
|
|
- [Attribute Lists]
|
|
|
|
|
|
|
|
[Attribute Lists]: ../setup/extensions/python-markdown.md#attribute-lists
|
2020-07-27 13:32:24 +03:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Adding buttons
|
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
In order to render a link as a button, suffix it with curly braces and add the
|
2021-10-10 13:19:14 +03:00
|
|
|
`.md-button` class selector to it. The button will receive the selected
|
2021-10-03 19:02:59 +03:00
|
|
|
[primary color] and [accent color] if active.
|
2020-07-27 13:32:24 +03:00
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
``` markdown
|
2021-10-10 13:19:14 +03:00
|
|
|
[Subscribe to our newsletter](#){ .md-button }
|
2020-07-27 13:32:24 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
2021-10-10 13:19:14 +03:00
|
|
|
[Subscribe to our newsletter][Demo]{ .md-button }
|
2020-07-27 13:32:24 +03:00
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
[primary color]: ../setup/changing-the-colors.md#primary-color
|
|
|
|
[accent color]: ../setup/changing-the-colors.md#accent-color
|
2021-10-10 13:19:14 +03:00
|
|
|
[Demo]: javascript:alert$.next("Demo")
|
2020-07-27 13:32:24 +03:00
|
|
|
|
|
|
|
### Adding primary buttons
|
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
If you want to display a filled, primary button (like on the [landing page]
|
2021-10-10 13:19:14 +03:00
|
|
|
of Material for MkDocs), add both, the `.md-button` and `.md-button--primary`
|
|
|
|
CSS class selectors.
|
2020-07-27 13:32:24 +03:00
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
``` markdown
|
2021-10-10 13:19:14 +03:00
|
|
|
[Subscribe to our newsletter](#){ .md-button .md-button--primary }
|
2020-07-27 13:32:24 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
2021-10-10 13:19:14 +03:00
|
|
|
[Subscribe to our newsletter][Demo]{ .md-button .md-button--primary }
|
2020-07-27 13:32:24 +03:00
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
[landing page]: ../index.md
|
2020-07-27 13:32:24 +03:00
|
|
|
|
|
|
|
### Adding icon buttons
|
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
Of course, icons can be added to all types of buttons by using the [icon syntax]
|
|
|
|
together with any valid icon shortcode, which can be easily found with a few keystrokes through the [icon search].
|
2020-07-27 13:32:24 +03:00
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
``` markdown
|
2021-10-03 19:02:59 +03:00
|
|
|
[Send :fontawesome-solid-paper-plane:](#){ .md-button .md-button--primary }
|
2020-07-27 13:32:24 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
[Send :fontawesome-solid-paper-plane:][Demo]{ .md-button .md-button--primary }
|
2020-07-27 13:32:24 +03:00
|
|
|
|
2021-10-03 19:02:59 +03:00
|
|
|
[icon syntax]: icons-emojis.md#using-icons
|
|
|
|
[icon search]: icons-emojis.md#search
|