Skip to content
Storybook

Button

Triggers an action or event, such as submitting a form, opening a dialog or saving changes.

Preview

React · live from the Storybook

HTML and CSS

The same component as plain HTML with pixels-ui.css, no framework needed.

Usage

  • Use one Primary button per view for the main action.
  • Start labels with a verb: “Save changes”, “Invite teammate”.
  • Use Danger only for actions that delete or cannot be undone.

Installation

Included in the core files. No extra install.

HTML
<link rel="stylesheet" href="/css/pixels-tokens.css">
<link rel="stylesheet" href="/css/pixels-ui.css">
<script src="/js/pixels-ui.js" defer></script>

Examples

Variants

Five variants, the same as the Figma “Variant” property. Pick the lowest emphasis that still makes the action clear.

Sizes

md 40px (default), sm 36px and xs 32px, as in Figma. md and sm use a 12px radius, xs 8px.

With icon

Icons sit at the start or end (Figma “Icon start” and “Icon end”).

Icon only

Square buttons in every size (Figma “Icon only = True”). They need an aria-label.

Pending and disabled

Click the first button. aria-busy shows a spinner and blocks repeat clicks.

API reference

Class / attributeTypeDescription
px-btnclassBase class. Primary variant, md size.
px-btn--secondary-grayclassFigma “Variant = Secondary”.
px-btn--tertiary-brandclassFigma “Variant = Ghost”.
px-btn--tertiaryclassFigma “Variant = Tertiary”.
px-btn--destructiveclassFigma “Variant = Danger”.
px-btn--sm · --xsclassSize (Figma “Size”): sm 36px, xs 32px. md 40px is the default.
px-btn--iconclassSquare icon-only button (Figma “Icon only = True”).
px-btn--blockclassFull width.
aria-busy="true"attributePending state. Put a .px-spinner inside.
disabledattributeDisabled state.

Figma properties

Button300 variants · page “Buttons”Open

Buttons trigger actions. Hierarchy: Primary (one per view) · Secondary (brand outline) · Secondary gray (neutral outline) · Secondary brand (brand tint) · Tertiary / Tertiary brand (text buttons with …

PropertyTypeValues
LabelText“Button”
Icon startBoolean—
Icon endBoolean—
Icon start swapInstance swap—
Icon end swapInstance swap—
VariantVariantPrimary Secondary Ghost Tertiary Danger
SizeVariantmd sm xs
StateVariantDefault Hover Pressed Focused Disabled
Icon onlyVariantFalse True
DirectionVariantLTR RTL

Design tokens

Component tokens from the Figma Component collection. Override them to restyle just this component.

TokenAliasLight value
--px-button-gapcontrol-gap8px
--px-button-md-heightspacing-4040px
--px-button-md-padding-xspacing-1616px
--px-button-md-radiusradius-1212px
--px-button-md-iconspacing-2020px
--px-button-sm-heightspacing-3636px
--px-button-sm-padding-xspacing-1212px
--px-button-sm-radiusradius-1212px
--px-button-sm-iconspacing-1616px
--px-button-xs-heightspacing-3232px
--px-button-xs-padding-xspacing-1212px
--px-button-xs-radiusradius-88px
--px-button-xs-iconspacing-1616px

Accessibility

  • Use a real <button>; Enter and Space activate it.
  • Icon-only buttons need aria-label.
  • Focus ring is two rings: surface gap + brand, 3:1 against any background.