Skip to main content

Overview

HuxButton is a versatile button component that provides multiple visual variants, sizes, loading states, and automatic WCAG AA contrast compliance. It adapts seamlessly to light and dark themes.

Basic Usage

Variants

HuxButton supports four visual variants through the HuxButtonVariant enum:

Primary

The default variant with a filled background using the primary color. Primary Button

Secondary

A subtle variant with a light background and border. Secondary Button

Outline

A transparent button with only a border outline. Outline Button

Ghost

A minimal transparent button without borders. Ghost Button

Sizes

Control button dimensions with three size options:

Small

Compact size for tight spaces (32px height). Small Button

Medium

Default size for most use cases (40px height). Medium Button

Large

Prominent size for important actions (48px height). Large Button

States

Loading State

Display a loading indicator while processing.

Disabled State

Disable button interaction.

Icons

Add icons to enhance button meaning:

Icon with Text

Icon with text Button

Icon-only Button

Icon-only Button

Square Icon-only Button

Width Control

Control button width behavior with the HuxButtonWidth enum:

Hug Content (Default)

Button width matches its content. Hug Content Button

Expand to Fill

Button takes full available width. Full Width Button

Fixed Width

Button has a specific width. Fixed Width Button

Custom Colors

Using Preset Colors

Custom Colors

API Reference

HuxButton Properties

HuxButtonVariant Enum

  • HuxButtonVariant.primary - Filled background with primary color
  • HuxButtonVariant.secondary - Light background with border
  • HuxButtonVariant.outline - Transparent with border only
  • HuxButtonVariant.ghost - Transparent without border

HuxButtonSize Enum

  • HuxButtonSize.small - 32px height, compact padding
  • HuxButtonSize.medium - 40px height, standard padding
  • HuxButtonSize.large - 48px height, generous padding

Common Patterns

Form Buttons

Action Buttons

Button Grid

Accessibility

HuxButton includes several accessibility features:

Automatic Contrast

Text color is automatically calculated to ensure WCAG AA compliance (4.5:1 contrast ratio) against any background color.

Semantic Roles

Buttons include proper semantic roles for screen readers.

Focus States

Keyboard navigation support with visible focus indicators.

Disabled States

Proper disabled state handling for assistive technologies.

Best Practices

  • Use Primary for the main action on a screen
  • Use Secondary for important but not primary actions
  • Use Outline for secondary actions that need visual weight
  • Use Ghost for subtle actions like “Cancel” or “Skip”
  • Use Large for important call-to-action buttons
  • Use Medium for most standard interactions
  • Use Small for compact interfaces or secondary actions
  • Use action-oriented labels: “Save”, “Delete”, “Continue”
  • Avoid generic labels: “OK”, “Submit”, “Button”
  • Keep labels concise but descriptive

Examples

Form Building

See buttons in action within forms

Loading States

Learn how to handle async operations

Custom Theming

Apply custom colors and themes

Accessibility

Ensure your buttons are accessible