Skip to content

Stateful Button

A shadcn/ui button that shows loading, success and error states while an async action runs.

stateful-button.vercel.app

Stateful Button website screenshot
Added
GitHub stars
17
License
MIT
Price
Free

About

About Stateful Button

Stateful Button is a React component that extends the standard shadcn/ui Button so it can report the life of an async action. It moves between idle, loading or progress, success and error states, and settles on its own: a resolved promise from onClick gives success, a rejected one gives error. State transitions run on an XState machine, and ARIA messages tell screen reader users what is happening.

The shadcn CLI adds stateful-button.tsx to components/ui and a stateful-button-machine.ts file to lib, so you own both. Demos cover default, secondary, destructive and outline variants, with load and progress examples. The project is MIT licensed. It suits file uploads, slow API calls, checkout submits and data processing.

Stateful Button features

6 features

  • Idle, loading, success and error states
  • Progress variant
  • XState state machine
  • ARIA messages for screen readers
  • Works with Promise-based handlers
  • Default, secondary, destructive and outline variants

Install Stateful Button

1 command

Terminal

$ npx shadcn@latest add https://stateful-button.vercel.app/r/stateful-button.json

What you can build with Stateful Button

3 use cases

  • Showing upload progress inside the submit button
  • Confirming a checkout payment with a success state
  • Surfacing a failed API call on the button itself

Pricing

Ship it with Pro

The directory is free. Pro adds 6,000+ blocks, 14 premium templates and the MCP server, so your AI editor installs them for you.

4.9/5 out of 5 · 150+ reviewsfrom 150+ founders and developers.

  • Secure checkout via Stripe
  • Code lives in your repo
  • Keep what you've shipped if you cancel
  • License terms

FAQ

Frequently asked questions

What Stateful Button is, how to install it, its license and its alternatives.

4.9 out of 5 from 150+ developers

Found your stack? Ship it.

6,000+ blocks, premium templates and MCP in every Pro plan. The directory stays free.

Get Pro