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" role="button"> Button Text </button>
<button class="mds-button mds-button--primary" type="button" disabled role="button"> Button Text </button>
Use for non-critical actions.
<button class="mds-button mds-button--secondary" type="button" role="button"> Button Text </button>
<button class="mds-button mds-button--secondary" type="button" disabled role="button"> Button Text </button>
Use for tertiary actions.
Replaces Flat, Deprecated by reducing padding and removing rounded corners on left and right edges.
<button class="mds-button mds-button--flat-no-background" type="button" role="button"> Button Text </button>
<button class="mds-button mds-button--flat-no-background" type="button" disabled role="button"> Button Text </button>
Use Flat, No Background variation instead.
Add Icons to provide additional affordance to a button.
<button class="mds-button mds-button--primary" type="button" role="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/assets/icons/mds_icons.svg#open-new--s"> </use>
</svg>
<span class="mds-button__text"> Copy Document </span>
</button>
<button class="mds-button mds-button--secondary" type="button" role="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/assets/icons/mds_icons.svg#open-new--s"> </use>
</svg>
<span class="mds-button__text"> Copy Document </span>
</button>
<button class="mds-button mds-button--flat-no-background" type="button" role="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="/assets/icons/mds_icons.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" role="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="/assets/icons/mds_icons.svg#person-padless">
<title>User</title>
</use>
</svg>
</button>
<button class="mds-button mds-button--icon-only mds-button--hover" type="button" disabled role="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="/assets/icons/mds_icons.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" role="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="/assets/icons/mds_icons.svg#caret-right--s"> </use>
</svg>
</button>
<button class="mds-button mds-button--small mds-button--secondary" type="button" role="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="/assets/icons/mds_icons.svg#caret-right--s"> </use>
</svg>
</button>
<button class="mds-button mds-button--small mds-button--flat-no-background" type="button" role="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="/assets/icons/mds_icons.svg#caret-right--s"> </use>
</svg>
</button>
<button class="mds-button mds-button--small mds-button--icon-only" type="button" role="button">
<svg class="mds-icon mds-button__icon mds-button__icon--right">
<use xlink:href="/assets/icons/mds_icons.svg#heart--s">
<title>User</title>
</use>
</svg>
</button>
mds-button--large
to an Icon-Only button. Icon size depends on button type and size. In some cases, markup requires a modifier class to display the correct icon size based on a button’s size.
Type |
Small button |
Medium button |
Large button |
---|---|---|---|
Primary |
Small Icon |
Small Icon |
Medium Icon |
Secondary |
Small Icon |
Small Icon |
Medium Icon |
Flat |
Small Icon |
Small OR Medium Icon |
Medium Icon |
Icon Only |
Small Icon |
Medium Icon |
N/A |
.mds-button--icon-m
class to a large Primary, large Secondary, and large or medium Flat button to display a medium-sized icon. --s
sized icon SVGs when including .mds-button--icon-m
to size the icon. .mds-button--icon-m
to a medium or small Primary or Secondary button or small Icon-Only or Flat button. <button>
element type when displaying buttons.div
or span
unless strictly required, such as when using the sort buttons in Data Tables.<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.
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. |
|
|
Sizes an icon as medium within a medium or large button. Always use for large Primary, Secondary and Flat buttons, medium Icon-Only buttons that need a medium-sized icon, and optionally for medium Flat buttons. Never use for other medium or small button types. |