Skip to content
On this page

Button

A control that can be pressed to trigger an action.

Demos

Configurable

NameValue
Props
action
weight
disabled
Slots
default
View
Reading direction

Default

Button actions

There are three button actions: default, progressive, and destructive.

Button weights

There are three button weights: normal, primary, and quiet.

Disabled

Add the disabled attribute for a disabled button.

With icon

Icon-only button

WARNING

Due to the lack of descriptive text, icon-only buttons require one of the following attributes: aria-label or aria-hidden.

The attribute aria-label has to be used on icon-only buttons to be understandable by screen reader users. Exceptions are buttons in component combinations, e.g. the button in the Combobox component, that are skipped by adding aria-hidden without negatively impacting the component's functionality.

Usage

Props

Prop nameDescriptionTypeValuesDefault
actionThe kind of action that will be taken on click.ButtonAction'default', 'progressive', 'destructive''default'
weightVisual prominence of the button.ButtonWeight'normal', 'primary', 'quiet''normal'

Events

Event namePropertiesDescription
click

Slots

NameDescriptionBindings
defaultButton content

CSS-only version

Markup structure

The CSS Button component uses the <button> element and the .cdx-button class.

Button actions

There are three button actions: default, progressive, and destructive. Use the following classes to apply these actions:

  • Default: cdx-button--action-default (class can be omitted since this is the default)
  • Progressive: cdx-button--action-progressive
  • Destructive: cdx-button--action-destructive

Button weights

There are three button weights: normal, primary, and quiet. Use the following classes to apply these actions:

  • Normal: cdx-button--weight-normal (class can be omitted since this is the default)
  • Primary: cdx-button--weight-primary
  • Quiet: cdx-button--weight-quiet

Disabled

Add the disabled attribute to the <button> element to get a disabled element with appropriate styles.

With CSS icon

You can use CSS icons within button content. To set up an icon within a CSS-only button, do the following:

  1. Add an empty span inside the button before the label with the class cdx-button__icon.
  2. Use the .cdx-mixin-css-icon() mixin with the @param-is-button-icon parameter set to true.

Note that in Firefox version 52 and below, full color support for icons inside CSS-only buttons is not available, and the icon will fall back to a single color.

WARNING

Be sure to add aria-hidden="true" to the icon element to hide it from screen readers.

Icon-only button

Add the cdx-button--icon-only class for an icon-only button.

WARNING

Be sure to add an aria-label attribute to the button element so it can be understandable to screen reader users.