Status Button

Shrinks into a spinner while your action runs, then shows a check or a cross.

no dependenciesMIT · free

Installation

npx shadcn@latest add https://ombakui.com/r/status-button.json

Usage

import { StatusButton } from "@/components/status-button";

// resolve = success, throw/reject = error
<StatusButton onAction={() => saveSettings(form)}>Save changes</StatusButton>

Props

PropTypeDefaultDescription
childrenReactNode–Button content while idle.
onAction() => Promise<unknown> | unknown–Runs on click. Resolve for success, throw or reject for an error.
successLabelReactNode"Saved"Label shown after success.
errorLabelReactNode"Try again"Label shown after an error.
resetAfternumber1800Milliseconds before returning to idle.
widthstring"10rem"Button width while not loading, any CSS length.
classNamestring–