Basic · Actions Stable

Button

What can I do next here?

9 variants × 6 states · 2 toggles
Primary label
Save changes (sample)
Secondary label
Copy link (sample)
Quiet label
Back (sample)
Danger label
Delete item (sample)
Large link labels
Get started, Learn more (sample)
Busy labels
Saving, Copying, Deleting (sample)
Copy label
Copy prompt, then Copied (sample)

Tab through the buttons to see focus, and press and hold one to see pressed. Turn on With icon to see the icon slot, and With copy for the copy pattern: press Copy prompt and the check and Copied take the glyph's and label's place without the button changing size (shown copied in the pressed state). Change Density and Radius in Design settings: height and corners follow; set Motion to still and the busy spinner stands still beside its words.

Used on screens

Add Pipeup to a page

Add the script tag and the keylink

Collect feedback from several reviewers

Hand the comments to an agentquiet
See every reviewer's comments on the pageprimaryquiet

Come back to a page later

Find a thread whose words were cutprimaryquiet
Reopen the page with its commentsquiet

Comment on any page in Safari

Answer Safari's one questionprimarysecondary
Write the first commentlinkprimaryquiet
Press Pipeup in the toolbarprimary
Copy or save from the toolbar menuquiet
Turn Pipeup on in Safariprimary

Go through every comment

See every comment in one placeprimaryquiet
Bring resolved threads backquiet

Manage a thread

Reply, react, or change your mindprimaryquiet
Delete a comment, asked once moredangerprimaryquiet
Resolve a thread, and bring it backquiet

Review a document

Copy every comment as Markdownquiet
Drop a pin on an exact spotlinkprimaryquiet
Comment on a few wordslinkprimaryquiet
Undo a cancelled commentlinkprimaryquiet
Write the commentlinkprimaryquiet

Review a slide deck

See every comment grouped by slideprimaryquiet
Drop a pin on a slidelinkprimaryquiet

Review on a phone

See every comment full widthprimaryquiet
Tap a block and typelinkprimaryquiet

Say who you are

Add your namequiet
Prompt to build this component

When to use it

When to use

  • To act on the current screen: save, create, copy, send, continue.
  • To go somewhere as the next step of a task, written as an <a class="ds-button"> link that looks like an action ("Get started", "See the example").
  • One primary per view for the obvious next step; everything else is secondary or quiet.

When not to use

  • For an action shown only as an icon: use cmp-icon-button.
  • For links inside running text: use a plain text link.
  • For choosing one of a few options: use cmp-segmented-control.
  • For moving between places in a product's navigation: use the navigation composites (sidebar, page header, site header).
Variants, anatomy, accessibility, interaction and content rules

Variants

  • primary — the one obvious next action in a view: an ink fill with light text. At most one per view.
  • secondary — every other action beside a primary, or the main action when it is not the obvious next step: a raised surface with an outline.
  • quiet — a low-emphasis action that should not compete: cancel, skip, "do it anyway", actions in dense rows and headers. No fill or outline at rest.
  • link — words that read as a link, with no fill, outline or side padding, so they line up with the text around them: a back link above a page title ("‹ Home"), or a small link in a strip. Muted at rest; darker and underlined on hover.
  • danger — an action that removes or overwrites something and cannot be undone silently: a solid danger fill. Its label names what is removed.
  • join-start — the first of two buttons joined as one control (a main action, then the chevron that opens its menu): its end corners are square. Combine it with a colour variant, for example ds-button ds-button--secondary ds-button--join-start.
  • join-end — the second of the pair, set right after a join-start button: its start corners are square, its border overlaps its partner's, and its padding is tight around one icon. When it holds only an icon, its label is a ds-visually-hidden span.
  • ringed — inside a ring that draws the control's edge (cmp-prompt-card ring): no outline of its own in any state. With join-end it keeps the thin divider between the two halves of a split button.
  • lg — a larger size for the ways to start on a public page's opening screen (two numbered choices at most). Combine it with one of the variants above, for example ds-button ds-button--primary ds-button--lg.

Anatomy

  • Root: <button class="ds-button ds-button--<variant>" type="button">, or <a class="ds-button ds-button--<variant>"> when it navigates.
  • Label: the text inside the root. Always present, even with an icon.
  • Icon (optional): <span class="ds-icon" data-icon="<name>"></span> before the label (after it only for chevron-right, chevron-down, arrow-right or external). The button sizes it to the small icon size.
  • Spinner (busy only): <span class="ds-button__spinner" aria-hidden="true"></span>, in the icon's place, with aria-busy="true" on the root and a label that says what is happening ("Saving").
  • Copy (optional, with-copy): the one way a button copies text, wherever it sits (a prompt, a step, a dialog). The root carries data-ds-copy, so cmp-code-block's script copies the nearest code block and sets data-copied for a moment. Inside, in this order:
    • <span class="ds-icon ds-button__copy-icon" data-icon="copy"></span> and <span class="ds-icon ds-button__done-icon" data-icon="check"></span>: the check replaces the copy glyph while the button has data-copied.
    • <span class="ds-button__label"> holding <span data-ds-copy-label>Copy prompt</span>, the words the script changes ("Copied", or "Press Ctrl+C" when the clipboard is blocked), over two <span class="ds-button__sizer" aria-hidden="true"> spans holding "Press Ctrl+C" and the label itself, so the widest words set the width and the button never changes size.

Accessibility

  • Use a native <button type="button"> (or type="submit" in a form) for actions and <a href> for navigation; never a div or span with a click handler.
  • The accessible name is the visible label. An icon next to a label is decorative and is hidden from assistive technology by the icon renderer.
  • Enter and Space activate a button; Enter activates a link. Focus shows the focus ring on every variant.
  • Disabled: use the disabled attribute on a <button>, and aria-disabled="true" (with no href) on a link. Prefer keeping an action enabled and explaining what is missing when pressed.
  • Busy: set aria-busy="true" and change the label to say what is happening; keep the button focusable so focus is not lost.
  • Copy: the accessible name is the label; the sizers are hidden from assistive technology, and a polite live region says "Copied to the clipboard" (cmp-code-block's script).
  • Text on every fill meets AA in every theme (text-on-accent on accent, accent-hover, accent-pressed and status-danger).

Interaction

  • Hover and press change colour over --ds-motion-quick on --ds-motion-ease, and nothing changes size or position (int-01, int-03).
  • Focus is always visible, and pressing or finishing never moves focus elsewhere (int-02).
  • Busy keeps the button's height and place: the spinner takes the icon's place and the label says what is happening (int-05).
  • Copy keeps the button's width, height and place while its glyph cross-fades into a check and its label's new words ("Copied") fade in, over --ds-motion-settle, for a moment; going back, the check cross-fades back to the copy glyph and the label returns at once. Focus stays on it (int-02, int-05). The spinner turns at a constant speed (--ds-motion-ease-steady) only while motion is allowed; under reduced motion it stands still and the words carry the meaning (int-04, int-06).

Content rules

  • Labels are a verb plus an object, in sentence case: "Create project", "Copy prompt", "Remove persona". One to three words, never a full sentence.
  • Name the result, not the mechanism: "Save changes", not "Submit".
  • Danger labels name what goes: "Delete journey", not "Delete" or "OK".
  • Busy labels use the -ing form of the same verb: "Create project" becomes "Creating".
  • Link-buttons that leave the product end with the external icon.

Do and don't

  • Do keep one primary per view, and put it where the eye ends (the right of a group, or the bottom of a form).
  • Do pair a primary with a secondary or quiet button for the alternative, never with a second primary.
  • Do use lg only on public pages, for the one or two ways to start on the opening screen.
  • Don't use danger for actions that can be undone; use secondary and offer undo.
  • Don't make a button wider with padding or spaces in the label; let the layout stretch it (a button in a ds-stack fills the column).
  • Don't build copying again in a component: a button that copies uses with-copy's parts.
  • Don't change a label's case, weight or colour per screen; add a variant instead (ask first).