Button
The Button element is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology. Once activated, it then performs an action, such as submitting a form or opening a dialog.
— Definition from the MDN web docs
Text
The text
property sets the label displayed in the button:
<qds-button text="Do something"></qds-button>
Writing guidelines
Make sure to review the Writing for user interfaces general guidelines.
- Buttons should use action verbs in the active imperative form.
- Avoid ambiguous actions like "learn more", "see more".
- Be contextual and use precise verbs that best describe what will happen when the user clicks on the button.
- In applications, append an ellipsis to the label when clicking the button will open a dialog.
Example
<div class="qds-controls qds-related flex-row"> <qds-button importance="emphasized" text="Save and exit"></qds-button> <qds-button text="Don't save"></qds-button> <qds-button text="Cancel"></qds-button> </div>
Icon
Use the icon-name
property to display an icon on the button. Quartz will look
into the default
icon library unless you specify another library using the
icon-library
property.
In Figma, enable the 🅵 icon
toggle to see the icon-name
property. See the
Usage > Icons instructions for more details.
<qds-button icon-name="alarm-clock" text="Set alarm"></qds-button>
Icon-only
Setting an icon-name
without text
will make the button show only an icon.
In Figma, enable the 🅵 icon
toggle and disable the 🅵 text
toggle.
<qds-button icon-name="alarm-clock"></qds-button>
Icon-only buttons should be used only in specific contexts:
-
to disclose advanced options/settings in a menu. Use subdued importance to make the button less prominent:
Loading...Live Editor<qds-button importance="subdued" icon-name="alarm-clock"></qds-button>
TODO: better example + replace with "kebab menu" icon + add the sub-menu.
-
to create toolbars in technical applications:
Loading...Live Editor<div class="qds-controls flex-row"> <div class="qds-controls qds-related flex-row"> <qds-button icon-name="alarm-clock"></qds-button> <qds-button icon-name="alarm-clock"></qds-button> </div> <div class="qds-controls qds-related flex-row"> <qds-button icon-name="alarm-clock"></qds-button> <qds-button icon-name="alarm-clock"></qds-button> <qds-button icon-name="alarm-clock"></qds-button> <qds-button icon-name="alarm-clock"></qds-button> </div> <div class="qds-controls qds-related flex-row"> <qds-button icon-name="alarm-clock"></qds-button> <qds-button icon-name="alarm-clock"></qds-button> <qds-button icon-name="alarm-clock"></qds-button> </div> </div>
TODO: use various icons when available.
Icon guidelines
- Prefer text buttons by default. Add an icon on the few most important buttons only.
- Don't put icons on every button.
- Don't use
emphasized
importance with an icon-only button.
Importance
Buttons follow the transversal Importance principle through its importance
property:
<div class="qds-controls qds-related flex-row"> <qds-button text="Standard"></qds-button> <qds-button importance="emphasized" text="Emphasized"></qds-button> <qds-button importance="subdued" text="Subdued"></qds-button> </div>
Standard
Use the standard
importance level for almost every button:
<div class="qds-controls qds-related flex-row"> <qds-button text="Action 1"></qds-button> <qds-button text="Action 2"></qds-button> <qds-button text="Action 3"></qds-button> </div>
Emphasized
Emphasize only one button on the screen or within a dialog:
<div class="qds-controls qds-related flex-row"> <qds-button importance="emphasized" text="Save and exit"></qds-button> <qds-button text="Don't save"></qds-button> <qds-button text="Cancel"></qds-button> </div>
Subdued
Use the subdued
importance level for less important or less commonly used
actions.
<div class="qds-controls flex-row justify-between"> <qds-button importance="subdued" text="Edit save preferences"></qds-button> <div class="qds-controls qds-related flex flex-row"> <qds-button importance="emphasized" text="Save"></qds-button> <qds-button text="Cancel"></qds-button> </div> </div>
Size
Buttons follow the transversal control size principles. Use
the standard
size unless you're in one of the specific contexts described on
that page.
<div class="qds-controls qds-related"> <div class="qds-controls qds-related flex flex-row"> <qds-label inline text="Standard size:"></qds-label> <qds-button importance="emphasized" text="Save"></qds-button> <qds-button text="Cancel"></qds-button> </div> <div class="qds-controls-large qds-related flex flex-row"> <qds-label inline size="large" text="Large size:"></qds-label> <qds-button size="large" importance="emphasized" text="Save"></qds-button> <qds-button size="large" text="Cancel"></qds-button> </div> <div class="qds-controls-small qds-related flex flex-row"> <qds-label inline size="small" text="Small size:"></qds-label> <qds-button size="small" importance="emphasized" text="Save"></qds-button> <qds-button size="small" text="Cancel"></qds-button> </div> </div>
Variant
Buttons have edge cases that can be set through the variant
property. Don't
use it unless you're in one of the specific contexts described here.
Hero
Use the hero
variant only on websites.
<div class="qds-controls qds-related flex-row"> <qds-button href="https://example.com/" variant="hero" text="Investor Relations"></qds-button> <qds-button href="https://example.com/" importance="emphasized" variant="hero" text="Our Purpose"></qds-button> <qds-button href="https://example.com/" importance="subdued" variant="hero" text="More"></qds-button> </div>
Destructive
Use the destructive
variant only for destructive actions that can't be
undone.
<div class="qds-controls qds-related flex-row"> <qds-button variant="destructive" text="Delete"></qds-button> <qds-button text="Cancel"></qds-button> </div>
Action
Buttons can display icons depending on their action.
Next
The next
action indicates that this button will navigate to a different page.
An example of a UI where this can be used is a wizard.
<qds-button href="https://example.com/" action="next" text="Next"></qds-button>
Dropdown
The dropdown
action indicates that this button opens a dropdown menu.
<div class="qds-controls qds-related flex-col"> <qds-button id="simple-multi-select" text="Select" action="dropdown"></qds-button> <qds-dropdown target="#simple-multi-select"> <div class="flex flex-col"> <qds-list-item list-action="multiselect" divider="hide" text="This is option 1"></qds-list-item> <qds-list-item list-action="multiselect" divider="hide" text="This is option 2"></qds-list-item> </div> </qds-dropdown> <qds-button text="Button 2"></qds-button> <qds-button text="Button 3"></qds-button> </div>
Layout
Order
Per the Norman/Nielsen recommendation, follow the Windows platform convention and put the default/emphasized button first:
<div class="qds-controls qds-related flex-row"> <qds-button importance="emphasized" text="Save"></qds-button> <qds-button text="Cancel"></qds-button> </div>
Grouping
Follow the transversal controls spacing guidelines when working with buttons:
<div class="qds-controls flex-row"> <qds-button importance="subdued" text="Open preferences"></qds-button> <qds-button importance="subdued" text="Cancel"></qds-button> <div class="qds-controls qds-related flex flex-row"> <qds-button text="Previous"></qds-button> <qds-button importance="emphasized" text="Next"></qds-button> </div> </div>
Additional options
Disabled
Use the disabled
attribute to disable a button. Clicks will be suppressed
until the disabled state is removed.
<div class="qds-controls qds-related flex-row"> <qds-button importance="standard" text="Standard" disabled></qds-button> <qds-button importance="emphasized" text="Emphasized" disabled></qds-button> <qds-button importance="subdued" text="Subdued" disabled></qds-button> <qds-button importance="destructive" text="Destructive" disabled></qds-button> </div>
Loading state
Accessibility
badge-description
Use the badge-description
attribute to give more context to screen readers
when a badge is being used.
In the following example, this button's badge will be read by screen readers as "2 new notifications".
<qds-button badge="2" badge-description="new notifications"></qds-button>