Skip to content

Button

The Button component provides a comprehensive solution for user interactions with multiple variants, loading states, icon support, and full accessibility compliance.

Basic Usage

Variants

Sizes

Loading State

Icon Support

Disabled State

Border Radius


Properties

intent

type: string

options: primary, secondary, success, warning, danger, info, ghost

default: ghost

Defines the visual intent and color scheme of the button.

variant

type: string

options: default, contained, outlined, text

default: default

Controls the button style variant. outlined creates a border-only button, text removes background, contained adds a border with background.

size

type: string

options: small, medium, large

default: medium

Controls the button size and padding.

rounded

type: string

options: none, sm, md, full

default: md

Controls the border radius of the button.

loading

type: boolean

default: false

Shows a loading spinner and disables the button. When true, the button becomes non-interactive.

disabled

type: boolean

default: false

Disables the button, making it non-interactive and applying disabled styling.

data-loading-text

type: string

default: undefined

Custom text announced to screen readers when the button is in loading state. Falls back to “Loading…” if not provided.

iconPosition

type: string

options: left, right

default: left

Controls the position of icon slots. Use with slot="icon-left" or slot="icon-right" for proper icon placement.

Slots

Default Slot

The main content of the button (text, icons, or other elements).

<Button>Click me</Button>

icon-left

Icon displayed on the left side of the button text.

<Button>
<svg slot="icon-left" class="h-4 w-4">...</svg>
Save
</Button>

icon-right

Icon displayed on the right side of the button text.

<Button iconPosition="right">
Next
<svg slot="icon-right" class="h-4 w-4">...</svg>
</Button>

Accessibility

This button component is designed with accessibility in mind and includes:

  • WCAG 2.1 AA compliance with proper color contrast ratios
  • Keyboard navigation support (Tab, Enter, Space)
  • Screen reader compatibility with proper ARIA attributes
  • Focus indicators that meet visibility requirements
  • Loading state announcements for assistive technology
  • Minimum touch target size of 44×44 pixels
  • Disabled state that doesn’t rely solely on color

Examples

Basic Usage

<Button intent="primary">Primary Button</Button>
<Button intent="secondary" variant="outlined">Secondary</Button>

With Loading State

<Button loading={true} data-loading-text="Saving...">
Save Document
</Button>

With Icons

<!-- Using default slot (backward compatible) -->
<Button intent="success">
<svg class="h-5 w-5">...</svg>
Success
</Button>
<!-- Using icon slots (recommended) -->
<Button intent="primary">
<svg slot="icon-left" class="h-4 w-4">...</svg>
Add Item
</Button>