Skip to content
Hazine

Async state buttons

1 of 5 shipped. Each take is a different structure, and the note under its title says how.

  • async state buttons

    The base four-state machine: width is floored at the idle measurement, presses while pending are ignored through aria-disabled so focus stays put, and every transition is announced.

    shadcn add @hazine/async-button-status-cycle

    Depends on button, @hazine/use-controllable-state, lucide-react

Planned 4

  • Progress Fill Button

    Progress is drawn inside the button as a fill layer under the label with text contrast kept on both sides of the edge; because button content is presentational to assistive technology, the value is exposed by a visually hidden sibling role=progressbar with aria-valuenow, and announcements are throttled to 25 percent steps.

  • Cancellable Async Button

    The pending state stays actionable instead of disabled: the same element switches purpose from start to stop with a spinner and a stop icon, and an AbortController is created per run and handed to the consumer.

  • Retry on Failure Button

    Failure is a durable state rather than a flash: the error text is attached with aria-describedby and announced through role=alert, attempts are counted up to a maximum, and after the last attempt a secondary help link slot appears.

  • Multi-Step Async Button

    The pending label is a sequence controlled by the consumer, each stage cross-fades vertically (instant under reduced motion) and is announced once, and the width is reserved for the longest stage label up front.