Button Stateful

Shows an action’s progress and result.

Installation

pnpm dlx shadcn@latest add @paneui/button-stateful

Usage

Examples

States

Use for async actions like saving, where the reader needs to see the result.

Variants

Without Tint

Sizes

Accessibility

While loading the button is disabled but stays focusable (focusableWhenDisabled) and sets aria-busy. The current label is announced through a polite live region.

Motion

With reduced motion the faces cross-fade and the width changes instantly.

See also Button.

API Reference

StatefulButton

A Button that swaps between idle, loading, success and error faces. Also accepts every prop of Button.

state= "idle"
"idle" | "loading" | "success" | "error"
Which face the button shows. idle shows the children and icon; loading disables it (it stays focusable).
children*
ReactNode
Idle label.
loadingText= "Working"
ReactNode
Label while loading, after a spinner.
successText= "Done"
ReactNode
Label on success, after a check.
errorText= "Try again"
ReactNode
Label on error, after a cross.
icon
ReactNode
Trailing icon shown only while idle.
tint= true
boolean
Tint the surface green / red on success / error (default variant only).
variant= "default"
Button variant
Passed to Button.
PropTypeDefaultDescription
state"idle" | "loading" | "success" | "error""idle"Which face the button shows. idle shows the children and icon; loading disables it (it stays focusable).
children*ReactNode—Idle label.
loadingTextReactNode"Working"Label while loading, after a spinner.
successTextReactNode"Done"Label on success, after a check.
errorTextReactNode"Try again"Label on error, after a cross.
iconReactNode—Trailing icon shown only while idle.
tintbooleantrueTint the surface green / red on success / error (default variant only).
variantButton variant"default"Passed to Button.
data-state
The current state.
Data attributeDescription
data-stateThe current state.