2020-07-27 12:32:24 +02: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 18:02:59 +02: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 12:32:24 +02:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
markdown_extensions:
|
|
|
|
- attr_list
|
|
|
|
```
|
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
See additional configuration options:
|
|
|
|
|
|
|
|
- [Attribute Lists]
|
|
|
|
|
|
|
|
[Attribute Lists]: ../setup/extensions/python-markdown.md#attribute-lists
|
2020-07-27 12:32:24 +02:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Adding buttons
|
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
In order to render a link as a button, suffix it with curly braces and add the
|
|
|
|
`#!css .md-button` class selector to it. The button will receive the selected
|
|
|
|
[primary color] and [accent color] if active.
|
2020-07-27 12:32:24 +02:00
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
``` markdown
|
2021-10-03 18:02:59 +02:00
|
|
|
[Don't click me](#){ .md-button }
|
2020-07-27 12:32:24 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
[Don't click me][Demo]{ .md-button }
|
2020-07-27 12:32:24 +02:00
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
[primary color]: ../setup/changing-the-colors.md#primary-color
|
|
|
|
[accent color]: ../setup/changing-the-colors.md#accent-color
|
|
|
|
[Demo]: javascript:alert$.next("Hi!")
|
2020-07-27 12:32:24 +02:00
|
|
|
|
|
|
|
### Adding primary buttons
|
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
If you want to display a filled, primary button (like on the [landing page]
|
|
|
|
of Material for MkDocs), add both, the `#!css .md-button` and
|
|
|
|
`#!css .md-button--primary` CSS class selectors.
|
2020-07-27 12:32:24 +02:00
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
``` markdown
|
2021-10-03 18:02:59 +02:00
|
|
|
[Don't click me](#){ .md-button .md-button--primary }
|
2020-07-27 12:32:24 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
[Don't click me][Demo]{ .md-button .md-button--primary }
|
2020-07-27 12:32:24 +02:00
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
[landing page]: ../index.md
|
2020-07-27 12:32:24 +02:00
|
|
|
|
|
|
|
### Adding icon buttons
|
|
|
|
|
2021-10-03 18:02:59 +02: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 12:32:24 +02:00
|
|
|
|
|
|
|
_Example_:
|
|
|
|
|
|
|
|
``` markdown
|
2021-10-03 18:02:59 +02:00
|
|
|
[Send :fontawesome-solid-paper-plane:](#){ .md-button .md-button--primary }
|
2020-07-27 12:32:24 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
_Result_:
|
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
[Send :fontawesome-solid-paper-plane:][Demo]{ .md-button .md-button--primary }
|
2020-07-27 12:32:24 +02:00
|
|
|
|
2021-10-03 18:02:59 +02:00
|
|
|
[icon syntax]: icons-emojis.md#using-icons
|
|
|
|
[icon search]: icons-emojis.md#search
|