Buttons express what action will occur when the user clicks or touches it. Buttons are used to initialize an action, either in the background or foreground of an experience. Each page can have one or two primary buttons. Any remaining calls-to-action should be represented as secondary buttons or another variation.
They should be used in situations where users might need to:
The HTML elements for buttons and links describe a very specific type of action that is going to be taken when they are used. It is important you know when to use which, as the distinction matters:
If pressing a Button results in a new URL, or the resultant UI makes sense as “a new browser tab”, that is a link <a>
. Everything else is a <button>
.
Finally, color alone does not suffice when conveying the meaning of buttons. Ensure that the text you use in the button matches the meaning you are trying to convey via color. For example, if you use the destructive button to point out a potential warning, make sure the text communicates the same message.
The base c-btn
looks like a plain text link. It removes all the styling of the native button.
Add the base class c-btn
to a <button>
or <a>
element to create the default button. Only use another style if a button requires more or less visual weight.
<!-- default button starts -->
<button class="c-btn">default button</button>
<!-- default button ends -->
To create the primary button, add the c-btn--primary
class to the c-btn
class.
Generally should only be used once per component screen at any one time. It is used for when there is an action that is clearly more important than the other actions and you need to draw attention to it. An example is when you have a “Save” and “Cancel” button. The “Save” is the primary action.
Not all features need to have primary actions, sometimes the actions are secondary to the content and are all of equal importance.
<!-- primary button starts -->
<button class="c-btn c-btn--primary">primary button</button>
<!-- primary button ends -->
To create the outline button, add the c-btn--outline
class to the c-btn
class.
<!-- outline button starts -->
<button class="c-btn c-btn--outline">outline button</button>
<!-- outline button ends -->
To create the plain button, add the c-btn--link
class to the c-btn
class.
<!-- link button starts -->
<button class="c-btn c-btn--link">link button</button>
<!-- link button ends -->
The SVG, element, or icon inside the button should have the o-icon
class and receives the c-btn--icon
class from the button. The position of the icon is on the left by default but you can position it on the right using c-btn--icon--right
, which applies the correct amount of space between the icon and the text.
<!-- Icon left button starts -->
<button class="c-btn c-btn--icon"><svg class="o-icon" aria-hidden="true"><use href="#approval"></use></svg> Button with icon</button>
<!-- default button ends -->
<!-- Icon right button starts -->
<button class="c-btn c-btn--icon c-btn--icon--right c-btn--icon--right">Button with icon <svg class="o-icon" aria-hidden="true"><use href="#approval"></use></svg></button>
<!-- icon--right button ends -->
To create the destructive button, add the c-btn--destructive
class to the c-btn
class. This button is used to indicate a destructive action to the user, like permanently erasing data.
<!-- destructive button starts -->
<button class="c-btn c-btn--destructive">destructive button</button>
<!-- destructive button ends -->
Buttons default size are determined by the c-btn
class. To change the size, add the following classes: c-btn--xs
for small and c-btn--lg
for large.
<!-- default small button starts -->
<button class="c-btn c-btn--xs">Small button</button>
<!-- default small button ends -->
<!-- default size button starts -->
<button class="c-btn">Default size button</button>
<!-- default size button ends -->
<!-- default large button starts -->
<button class="c-btn c-btn--lg">Large button</button>
<!-- default large button ends -->
To allow the button’s width to take up the entire width available, apply the c-btn--block
class to the button.
<!-- default block button starts -->
<button class="c-btn c-btn--block">Block button</button>
<!-- default block button ends -->
Class | Type | Purpose |
---|---|---|
c-btn |
Secondary | For secondary actions on each page. All buttons, are secondary by default. |
c-btn--primary |
Primary | For the principal call to action on the page. |
c-btn--outline |
Tertiary | When an action does not require primary dominance on the page. |
c-btn--link |
Plain button | Use for less important or less commonly used actions since they’re less prominent. |
c-btn--icon--left c-btn--icon--right |
Supporting | When words are not enough, icons can be used in buttons to better communicate what the button does. |
c-btn--destructive |
Destructive | When an action has potentially destructive effects on the user’s data (delete, remove, etc). |