Button

Clickable action element.

Also known as:
  • Action Button
  • Action Link
  • Chunky Buttons
  • Circular Button
  • Button Link
  • Button Tile
  • Button Timed
  • Call to Action Link
  • Close Button
  • Card Button
  • Condensed Button
  • Copy Button
  • Floating Action Button
  • Floatbutton
  • Form buttons
  • Link button
  • Primary Button
  • Secondary Button
  • Tertiary Button
  • Ghost Button
  • Icon Button
  • Text Button

Overview

Purpose

The Button component clickable action element.within our design system. It follows our primitive layer principles, ensuring consistency and reusability across applications.

When to Use

  • Use when you need triggering user interactions
  • Appropriate for actions contexts
  • Follows primitive component patterns

When Not to Use

  • Avoid when simpler alternatives exist
  • Don't use for navigation or form submission
  • Consider alternatives for edge cases

Live Example

import React from 'react';
import Button from './components/Button';
// PropsBridge writes props to /props.json
import props from '/props.json';

export default function App() {
  return (
    <div style={{ padding: '2rem', display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh' }}>
      <Button
        variant={props.variant || 'primary'}
        size={props.size || 'medium'}
        disabled={props.disabled || false}
        loading={props.loading || false}
      >
        Button Example
      </Button>
    </div>
  );
}

Anatomy

Understanding the structure of the Button component helps ensure proper implementation and customization.

Anatomy data not yet defined for this component. Define anatomy in the component contract file (Button.contract.json).

Variants & States

import React from 'react';
import Button from './components/Button';
// PropsBridge writes props to /props.json
import props from '/props.json';

export default function App() {
  return (
    <div style={{ padding: '2rem', display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh' }}>
      <Button
        variant={props.variant || 'primary'}
        size={props.size || 'medium'}
        disabled={props.disabled || false}
        loading={props.loading || false}
      >
        Button Example
      </Button>
    </div>
  );
}

API Reference

Props

NameTypeRequiredDefaultDescription
sizeButtonSizeNo'medium'
variantButtonVariantNo'primary'
loadingbooleanNofalse
disabledbooleanNofalse
classNamestringNo''
titlestring; // Ensure you have a title prop for accessibilityNo''
ariaLabelstringNo
ariaExpandedbooleanNo
ariaPressedbooleanNo
roleReact.AriaRoleNo
asChildbooleanNofalse

Accessibility

Standards Compliance

This component follows WCAG 2.1 AA guidelines and includes proper ARIA attributes, keyboard navigation, and screen reader support.

Common Pitfalls

  • Overloaded with too many variants
  • missing accessible name for icon-only.

Accessibility Checklist

  • Keyboard navigation support
  • Screen reader compatibility
  • Color contrast compliance
  • Focus management
  • ARIA attributes
  • Reduced motion support

Content Guidelines

Voice

Action-oriented, clear, and concise

Tone

Direct and confident

Copy Examples

Do

Save changes

Don't

Click here to save your changes

Do

Delete

Don't

Remove this item from the list

Do

Sign in

Don't

Sign in to your account

UI Copy Patterns

  • Use verbs (Save, Delete, Submit)
  • Keep labels short (1-2 words)
  • Be specific about the action
  • Avoid "Click here" or vague instructions

Usage Guidelines

✓ Do

  • Use consistent spacing and sizing
  • Follow established patterns
  • Provide clear labels and descriptions
  • Test with assistive technologies

✗ Don't

  • Override core functionality
  • Use without proper context
  • Ignore accessibility requirements
  • Modify without design system approval

Examples

Basic Usage

Simple implementation with default props and common configurations.

import React from 'react';
import Button from './components/Button';
// PropsBridge writes props to /props.json
import props from '/props.json';

export default function App() {
  return (
    <div style={{ padding: '2rem', display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh' }}>
      <Button
        variant={props.variant || 'primary'}
        size={props.size || 'medium'}
        disabled={props.disabled || false}
        loading={props.loading || false}
      >
        Button Example
      </Button>
    </div>
  );
}

Advanced Usage

Complex patterns including composition, state management, and real-world scenarios.

import React, { useState } from 'react';
import Button from './components/Button';

export default function App() {
  const [loading, setLoading] = useState(false);
  const [count, setCount] = useState(0);
  
  const handleClick = () => {
    setLoading(true);
    setTimeout(() => {
      setCount(c => c + 1);
      setLoading(false);
    }, 1000);
  };
  
  return (
    <div style={{ padding: '2rem', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '1.5rem' }}>
      <h3>Button Group Example</h3>
      <div style={{ display: 'flex', gap: '0.5rem' }}>
        <Button variant="primary" size="medium">Primary</Button>
        <Button variant="secondary" size="medium">Secondary</Button>
        <Button variant="tertiary" size="medium">Tertiary</Button>
      </div>
      
      <h3>Async Action</h3>
      <div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
        <Button 
          variant="primary" 
          loading={loading} 
          onClick={handleClick}
        >
          Click to Increment
        </Button>
        <span>Count: {count}</span>
      </div>
      
      <h3>Size Comparison</h3>
      <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
        <Button size="small">Small</Button>
        <Button size="medium">Medium</Button>
        <Button size="large">Large</Button>
      </div>
    </div>
  );
}

Development Tools

Use these tools to analyze the component's performance, design tokens, and accessibility during development.

Changelog

v2.0.0
  • changedRenamed `onClick` prop to `onPress` for consistency
  • addedAdded `variant` prop with "primary" and "secondary" options
  • changedUpdated styling approach to use CSS classes
v1.5.0
  • addedAdded `isLoading` prop for loading state
  • fixedFixed focus styles for keyboard navigation
v1.0.0
  • addedInitial release of Button component

Contribute

Help us improve the Button component documentation. Found an issue or have suggestions?

Related Components