Button

Button with a background color

Overview

  • Available since: New York
  • A11Y: WCAG 2.1 AA

Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.

Loading playground

When to use

Use buttons to communicate actions users can take and to allow users to interact with the page. Each page should have only one primary button, and any remaining calls to action should be represented as lower emphasis buttons.

When not to use

Do not use buttons as navigational elements. Instead, use links when the desired action is to take the user to a new page.


Anatomy

  1. Icon (optional): Visual element next to the label that emphasizes the action
  2. Label: Describes the action of the button
  3. Container: Frame containing the button
  4. Slot (optional): Container inside the button where you can add a component, and takes the place of the label and icon. Use a slot to clarify or emphasize a button’s function. Some additions make sense, such as a heading component. Other additions don’t make sense, such as a button (within a button).

Usage

Use different button variants and button types to guide the user through your design or workflow. Buttons can also help express the hierarchy of actions with variant styles. Choose the appropriate button style based on the importance of each action. Be sure to also consider the button type and configuration for each action.
Buttons with text have more visual impact and offer more context than iconic buttons. Iconic buttons should provide necessary visual context but aren’t meant to compete for the user's attention.

Variants

Learn about the attributes of button.

Types

The button component has these different types.

See usage guidance for bare button

See usage guidance for iconic button

See usage guidance for split button

See usage guidance for stateful button

Colors

A button has the following different color variants: primary, primary positive, primary negative, secondary, secondary positive, secondary negative, and tertiary.

Color variants are ways to visually show the order of importance for buttons in the display. By applying variants to buttons, you can help the user make a decision quickly.

Primary

Use the primary button for the key action in a workflow or a component.

button variant primary

A primary button is designed to grab the user's attention and stand out from other buttons. Use one primary button per display in a workflow.

button variant primary example

In this example, 'Save' is the primary action for the workflow. Its variant style makes it distinguishable from the 'Cancel' button.

You can use a primary button in isolated views or components (like a modal).

button variant primary example

In this example, the primary variant is the main action the user should take within the modal. The primary button appears in its own view, so it doesn't conflict with the primary action of the page behind the modal.

Primary negative variant

Use the primary (negative) variant for critical or destructive actions, such as permanently deleting something.

button variant primary negative

The primary (negative) button clearly communicates the severity of a destructive action with its style.

button variant primary negative example

In this example, the modal informs the user that they are about to permanently delete a folder. This is a critical action, so the button uses the primary negative variant.

Primary positive variant

Use the primary (positive) variant for confirming an object or action.

button variant primary positive

Remember that the primary (positive) variant shouldn't exist by itself. Always pair this variant with a primary (negative) action to provide the user with two distinct choices.

button variant primary positive example

In this example, the user can decline or approve the request. The primary (positive) variant and the primary (negative) variant clearly show the two choices available to the user.

If you want to use only one button, use the primary variant instead.

Secondary

Use the secondary variant when the action is supplemental to completing a workflow. The secondary variant is the default for button.

button variant secondary

The secondary variant has a recognizable appearance with a style that keeps it from standing out in the display.

button configurations text 2

The actions 'Assign to me' and 'Resolve' are secondary variants of a button. They complement the primary action, ‘Save’.

Secondary negative variant

Use the secondary (negative) variant when there are multiple instances of a negative and positive action within a single view.

button variant secondary negative

The secondary (negative) variant clearly communicates denying something or taking a destructive action. It's also an alternative to the prominent primary (negative) variant.

Secondary positive variant

Use the secondary (positive) variant when there are multiple instances of a negative and positive action within a single view.

button variant secondary positive

The secondary (positive) variant clearly communicates confirming an action. It's also an alternative to the prominent primary (positive) variant.

button variant secondary negative and positive example

In this example, the secondary (positive) and secondary (negative) variants show multiple choices within a single view.

Tertiary

Use the tertiary variant for optional or repeated actions.

button variant tertiary

The tertiary button complements the primary and secondary variants but doesn't visually compete with either variant.

button variant tertiary example hover

In this example, the 'Edit' and 'Download' actions are optional, so they use the tertiary button style.

Sizes

A button has three sizes: small (sm), medium (md), and large (lg). Size helps reinforce visual hierarchy, differentiate the different types, and indicate the functions of buttons. Choose a size that fits with your display and complements the surrounding content.

Small

Use the small size for areas that have limited space. This size is also recommended for non-essential actions.

button size small

Medium

Use the medium size alongside similarly sized components and content.

button size medium

Note: medium is the default size for button.

Large

Use the large size to emphasize a button and to capture the user's attention.

button size large

Configurations

Learn how to customize button by configuring the available properties.

Text

The default configuration for a button is plain text within a container, which can have different styles based on the variant you choose.

button configurations text

The text button clearly communicates that user's input posts when they select the button.

Text buttons can clearly communicate all available actions in a display.

button variant tertiary example hover

In this example, the text buttons show all available actions the user can take.

Text with icon

A button can also contain text with an icon. Including an icon can provide a visual reference that reinforces the action. However, don't add an icon solely for decoration. An icon should add value to the button by providing the user with additional context.

button variant tertiary example hover

In this example, the button has a text label with a plus icon to reinforce the button action.

Design recommendations

button application primary do
Do

Use tertiary buttons for multiple repeated actions.

button application primary dont
Don’t

Avoid using multiple primary buttons for repeated actions. This can create unnecessary visual noise.

Remember that not every view needs a primary action. If none of the actions are essential to the workflow, you don't have to include a primary button.

button application grouping do
Do

Use consistent button types to grouping related actions together. In this example, the group of buttons shares the same type. The buttons establish a visual relationship based on style and position.

button application grouping dont
Don’t

Avoid mixing button styles in a group. This creates visual complexity and requires more of the user's attention.

When grouping three or more buttons in one area, consider each button's impact on the task or workflow to determine which variant to use. Also use spacing to build relationships between buttons, divide actions, or break up functions.

Alignment and positioning

Each button's position should be based on importance starting from the right, especially when grouped with other buttons. This position serves as an anchor where the user can consistently look for primary actions across multiple views.

Remember to position any page-level actions at the top of the page. This location communicates that the button actions affect the content underneath. This positioning also applies to sections and components within content areas or containers. Keep these position patterns consistent to establish familiarity with the user. Consistent button placement and design makes natural sense to users, meets their expectations, and helps them navigate the task or workflow.

UI text guidelines

Consider these recommendations for labeling a button:

  • Start with a verb to describe a specific action. This sets the expectation of what happens next.
  • Use short labels. Two words is ideal. Three is OK. If needed for clarity, four is acceptable.
  • Avoid commas, periods, and other punctuation
  • Add an object to the verb if additional context or clarity is needed
    • For example, “Add table"
  • Add an article (like “a” or “an”) to add a more human, conversational tone
    • For example, “Add a person”
  • Use the same verb tense if there are multiple buttons
    • For example, two buttons could be “Apply” and “Close,” both of which are present tense

Behavior

Learn how button behaves when the display changes or a user interacts with the component.

States

Button has the following states: default, hover, pressed, focus and disabled.

Primary

State Initial Positive Negative
Default now-button now-button now-button
Hover now-button now-button now-button
Pressed now-button now-button now-button
Focus now-button now-button now-button
Disabled now-button now-button now-button

Secondary

State Initial Positive Negative
Default now-button now-button now-button
Hover now-button now-button now-button
Pressed now-button now-button now-button
Focus now-button now-button now-button
Disabled now-button now-button now-button

Tertiary

State Initial
Default now-button
Hover now-button
Pressed now-button
Focus now-button
Disabled now-button

Responsive behavior

Learn how button responds to changes in a container or display.

Overflow

Consider using an overflow menu when the container or display can't fit all buttons. Overflow menus store actions in a dropdown menu that is accessible by the user.

Truncation

Truncation behavior isn't available for the button label. All button labels should be concise to help the user identify the action and decide whether they should take that action.

Usability

Internationalization

When the display translates to a right-to-left (RTL) language, the button flips its orientation. If the button includes an icon, the icon appears to the right of the label.

For RTL languages, an icon flips only if it communications direction.

button usability internationalization

Accessibility

Keyboard interactions

  • Tab: Shifts focus to the button
  • Space or Enter: Launches the button action