Buttons

figma:ready
react:ready
scss:ready
freemarker:ready
vue:ready
webComponent:ready

Import


@import 'settings-tools/all-settings';
@import 'components/c.button';

Basic usage

To create a solid button you have one main class to apply mc-button, and wrap the text inside the button in a span.mc-button__label. While the text without span will look mostly fine, we use it to opticaly align the characters baseline in the button. With unwraped text, buttons using icons will break layout.


<button type="button" class="mc-button">
<span class="mc-button__label"> Label </span>
</button>

Note that if you wish, you can also use the mc-button with an HTML tag <a />:


<a href="#" class="mc-button">
<span class="mc-button__label"> Label </span>
</a>

Variations

Available themes

  • solid
  • bordered
  • bordered-neutral
  • solid-neutral
  • solid-primary-02 (no longer maintened)
  • bordered-primary-02 (no longer maintened)
  • solid-danger
  • bordered-danger

example :


<a href="#" class="mc-button mc-button--neutral">
<span class="mc-button__label"> Label </span>
</a>
<a href="#" class="mc-button mc-button--bordered-neutral">
<span class="mc-button__label"> Label </span>
</a>

Available sizes

You can use one of the 3 available sizes :

  • small : mc-button--s
  • medium : this is the default style so you don't need to add a modifier class
  • large : mc-button--l;

<a href="#" class="mc-button mc-button--s">
<span class="mc-button__label"> Label </span>
</a>
<a href="#" class="mc-button">
<span class="mc-button__label"> Label </span>
</a>
<a href="#" class="mc-button mc-button--l">
<span class="mc-button__label"> Label </span>
</a>

Responsive classes

breakpointmc-button--smc-button--mmc-button--l
From breakpoint mmc-button--s@from-mmc-button--m@from-mmc-button--l@from-m
From breakpoint lmc-button--s@from-lmc-button--m@from-lmc-button--l@from-l
From breakpoint xlmc-button--s@from-xlmc-button--m@from-xlmc-button--l@from-xl
From breakpoint xxlmc-button--s@from-xxlmc-button--m@from-xxlmc-button--l@from-xxl

Width modifiers

To manage display of your button, you have 2 availables classes :

  • mc-button--fit : natural size (Applied by default)
  • mc-button--full : full width

<a href="#" class="mc-button mc-button--full">My button</a>

Responsive classes

breakpointmc-button--fullmc-button--fit
From breakpoint mmc-button--full@from-mmc-button--fit@from-m
From breakpoint lmc-button--full@from-lmc-button--fit@from-l
From breakpoint xlmc-button--full@from-xlmc-button--fit@from-xl
From breakpoint xxlmc-button--full@from-xxlmc-button--fit@from-xxl

Variations with icons

You can add an icon into any buttons you want.

You only need to add the mc-button__icon CSS class to your icon HTML tag.


<a href="#" class="mc-button">
<span class="mc-button__label">Label</span>
<svg class="mc-button__icon">
<use xlink:href="#icon" />
</svg>
</a>

Icon sizes

The size of the icons is relative to the size of the buttons and corresponds to the rules detailed in the table below:

Button sizeIcon onlyIcon + text
Small1.5mu (24px)1.5mu (24px)
Medium2mu (32px)1.5mu (24px)
Large2mu (32px)2mu (32px)

Icon and text

Icon only and square button

You can also use icon only without text into a square button.

To do that, you shoud add the mc-button--square modifier to the button to display it as a square.


<a href="#" class="mc-button mc-button--square">
<svg class="mc-button__icon">
<use xlink:href="#icon" />
</svg>
</a>

Icon position

When an icon is used in a button with text, it is possible to position the icon to the left or right of the text.

Behaviors

Standard button states :

  • hover
  • active
  • focus
  • disabled

Customization and Mixins

Customize buttons using tokens

Our buttons themes are built by looping through the associated design tokens. This mean that you can override or create buttons themes and the associated classes names using only tokens.

Read first

Read our customization documentation first first to see how to customize tokens.

Create a json file in [your/src]/properties/color/button.json

You can override the existing themes by re-definiing an existing key :


{
"color": {
"button": {
"danger": {
"background": {
"value": "{color.custom.500.value}"
},
"font": {
"value": "{color.custom.000.value}"
},
"focus": {
"border": {
"value": "{color.custom.700.value}"
}
},
...etc
}
}
}

Which will change the apearence of the .mc-button--danger theme.

But you can also create an entierly new theme just by adding a new key :


{
"color": {
"button": {
"foo-bar": {
"background": {
"value": "{color.custom.500.value}"
},
"font": {
"value": "{color.custom.000.value}"
},
"focus": {
"border": {
"value": "{color.custom.700.value}"
}
},
...etc
}
}
}

Which will create the .mc-button--foo-bar theme and associated classes.

The button mixin

If you need to create a new button theme you need to define a new SASS map, see below :


$my-map: (
'background': red,
'font': green,
'border': yellow,
'hover': (
'background': blue,
'font': white,
),
'focus': (
'border': purple,
),
'active': (
'background': 'blue',
),
);

Now the map of your theme is define you can use the mixin set--button-theme.


.mc-button--my-custom-theme {
@include set-button-theme($my-map);
}

Then, it will generate something like this :


.mc-button--my-custom-theme {
color: green;
border: 2px solid yellow;
background-color: red;
}
.mc-button--my-custom-theme:hover,
.mc-button--my-custom-theme.is-hover {
background-color: blue;
color: white;
}
.mc-button--my-custom-theme:hover,
.mc-button--my-custom-theme.is-hover {
background-color: blue;
color: white;
}
.mc-button--my-custom-theme:focus,
.mc-button--my-custom-theme.is-focus {
border-color: purple;
}