• Light
  • Dark
  • Darkest
  • Medium
  • Large
  • LTR
  • RTL
  • Default
  • Express

Button - Primary

Component status
Contribution
Last releasedMay 23, 2023
Current version@spectrum-css/button@10.1.1

Usage notes


The primary button is used for medium emphasis.

Variants


Sizing
Verified

S

M (default)

L

XL

Show markup
<div class="spectrum-Examples">
  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">S</h4>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeS">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeS">
      <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeS spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>
  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">M (default)</h4>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeM">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeM">
      <svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeM spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>

  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">L</h4>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeL">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeL">
      <svg class="spectrum-Icon spectrum-Icon--sizeL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeL spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>

  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">XL</h4>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeXL">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeXL">
      <svg class="spectrum-Icon spectrum-Icon--sizeXL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--fill spectrum-Button--primary spectrum-Button--sizeXL spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeXL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>
</div>

Disabled
Verified

Show markup
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--fill spectrum-Button--primary" disabled>
  <span class="spectrum-Button-label">Edit</span>
</button>

<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--fill spectrum-Button--primary" disabled>
  <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
    <use xlink:href="#spectrum-icon-18-Edit" />
  </svg>
  <span class="spectrum-Button-label">Edit</span>
</button>

<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--fill spectrum-Button--primary spectrum-Button--iconOnly" aria-label="Edit" disabled>
  <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
    <use xlink:href="#spectrum-icon-18-Edit" />
  </svg>
</button>

Outline
Verified

S

M (default)

L

XL

Show markup
<div class="spectrum-Examples">
  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">S</h4>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeS">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeS">
      <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeS spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>
  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">M (default)</h4>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeM">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeM">
      <svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeM spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>

  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">L</h4>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeL">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeL">
      <svg class="spectrum-Icon spectrum-Icon--sizeL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>
    
    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeL spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>

  <div class="spectrum-Examples-item">
    <h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">XL</h4>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeXL">
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeXL">
      <svg class="spectrum-Icon spectrum-Icon--sizeXL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
      <span class="spectrum-Button-label">Edit</span>
    </button>

    <button class="spectrum-Button spectrum-Button--outline spectrum-Button--primary spectrum-Button--sizeXL spectrum-Button--iconOnly" aria-label="Edit">
      <svg class="spectrum-Icon spectrum-Icon--sizeXL" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-icon-18-Edit" />
      </svg>
    </button>
  </div>
</div>

Outline - Disabled
Verified

Show markup
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--primary" disabled>
  <span class="spectrum-Button-label">Edit</span>
</button>

<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--primary" disabled>
  <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
    <use xlink:href="#spectrum-icon-18-Edit" />
  </svg>
  <span class="spectrum-Button-label">Edit</span>
</button>

<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--primary spectrum-Button--iconOnly" aria-label="Edit" disabled>
  <svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
    <use xlink:href="#spectrum-icon-18-Edit" />
  </svg>
</button>

Custom Properties API


This component can be modified via its --mod-* prefixed custom properties. A list of those prefixed custom properties can be found here.

Migration Guide


Fill or Outline class required

All buttons now require either the .spectrum-Button--fill or .spectrum-Button--outline class.

Primary replaced by Primary with Outline

Replace all .spectrum-Button--primary with .spectrum-Button--primary .spectrum-Button--outline.

Primary Quiet replaced by Secondary with Outline

Replace all .spectrum-Button--primary .spectrum-Button--quiet with .spectrum-Button--secondary .spectrum-Button--outline.

Icon Only

Add the .spectrum-Button--iconOnly class to apply the correct styling when an icon is used without a label.
Provide an aria-label on the button itself when using this variant for accessibility.

T-shirt sizing

Button now supports t-shirt sizing and requires that you specify the size of button by adding a .spectrum-Button--size* class.

Change workflow icon size

Previously, all Buttons used .spectrum-Icon--sizeS. This has changed:

Button classname Workflow icon classname
.spectrum-Button--sizeS .spectrum-Icon--sizeS
.spectrum-Button--sizeM .spectrum-Icon--sizeM
.spectrum-Button--sizeL .spectrum-Icon--sizeL
.spectrum-Button--sizeXL .spectrum-Icon--sizeXL