Buttons trigger interactions throughout the experience.
Use for highest-priority actions that are required to complete the user’s task.
<button class="mds-button mds-button--primary" type="button"> Button Text </button>
<button class="mds-button mds-button--primary" type="button" disabled> Button Text </button>
Use for non-critical actions.
<button class="mds-button mds-button--secondary" type="button"> Button Text </button>
<button class="mds-button mds-button--secondary" type="button" disabled> Button Text </button>
Use for tertiary actions.
<button class="mds-button mds-button--flat" type="button"> Button Text </button>
<button class="mds-button mds-button--flat" type="button" disabled> Button Text </button>
Add Icons to provide additional affordance to a button.
<button class="mds-button mds-button--primary" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#open-new--s"> </use>
</svg>
<span class="mds-button__text"> Copy Document </span>
</button>
<button class="mds-button mds-button--secondary" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#open-new--s"> </use>
</svg>
<span class="mds-button__text"> Copy Document </span>
</button>
<button class="mds-button mds-button--flat" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/icons/mds.svg#open-new--s"> </use>
</svg>
<span class="mds-button__text"> Copy Document </span>
</button>
Use for toolbars and displays where words won't comfortably fit alongside icons.
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="/icons/mds.svg#person-padless">
<title>User</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only mds-button--hover" type="button" disabled>
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="/icons/mds.svg#person-padless">
<title>User</title>
</use>
</svg>
</button>
remove
or remove--s
to close Modals, Notifications, and Tooltip prompts.remove
or remove--s
to remove an item from a list.$mds-space-inline-left-2-x
space and vertically align middle the icon-only button.Configure button size and icon size independently within the button.
Each button variation allows for small, medium, and large sizes. The default size is medium, and you can use modifier classes to make the button smaller (mds-button--small
) or larger (mds-button--large
).
<button class="mds-button mds-button--small mds-button--primary" type="button">
<span class="mds-button__text"> Continue </span>
<svg class="mds-icon mds-button__icon mds-button__icon--right" aria-hidden="true">
<use xlink:href="/icons/mds.svg#caret-right--s"> </use>
</svg>
</button>
<button class="mds-button mds-button--small mds-button--secondary" type="button">
<span class="mds-button__text"> Continue </span>
<svg class="mds-icon mds-button__icon mds-button__icon--right" aria-hidden="true">
<use xlink:href="/icons/mds.svg#caret-right--s"> </use>
</svg>
</button>
<button class="mds-button mds-button--small mds-button--flat" type="button">
<span class="mds-button__text"> Continue </span>
<svg class="mds-icon mds-button__icon mds-button__icon--right" aria-hidden="true">
<use xlink:href="/icons/mds.svg#caret-right--s"> </use>
</svg>
</button>
<button class="mds-button mds-button--small mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="/icons/mds.svg#heart--s">
<title>User</title>
</use>
</svg>
</button>
mds-button--large
to an icon-only button.Icon size is predetermined and applied automatically to with icon and icon-only buttons. To avoid undesirable scaling of icon artwork, use the chart below to choose the correct icon size to use in your button.
Type | Small Button | Medium Button | Large Button |
---|---|---|---|
Primary |
|||
Secondary |
|||
Flat |
Small OR Default Icon* |
||
Icon Only |
— |
* Default size icon may be used within the medium flat button by applying the mds-button--flat-icon-m
modifier class to the block level.
<button>
element type when displaying buttons.<a>
element cannot be triggered from a spacebar
press, only from an enter
or return
press.spacebar
, enter
, or return
.<title>
tag on the svg
within an icon-only button to describe the button’s intent for icon-only buttons. See Iconography accessibility section.box-shadow
property to create an outline. Internet Explorer and Safari have known issues rendering these outlines when using the browser's zoom functionality. This visual defect doesn't affect the functionality of the component.
Class |
Applies to |
Outcome |
---|---|---|
|
|
Applies base button styles to an element. Always couple with a variant for semantics, though a standalone |
|
|
Shows primary button, to be coupled with |
|
|
Shows secondary button, to be coupled with |
|
|
Shows tertiary button, to be coupled with |
|
|
Applies the icon-only styles to a button element. Specifically, it removes the border strokes and background treatments found on primary and secondary buttons. |
|
|
Adjusts styling to render a small button. |
|
|
Adjusts styling to render a large button. |
|
|
Positions an icon to the left of a button label. |
|
|
Positions an icon to the right of a button label. |
|
|
Applies default size to the icon in a medium flat button. Never apply this class when using a small icon. |