For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
Shadcn Labs/

Status Button

A button that morphs from idle to loading to success or error, resizing smoothly while its label and icon crossfade. A React component built on View Transitions, installed with the shadcn CLI.

acme-web

main · a1f9c2e · 2 minutes ago

Installation

$ pnpm dlx shadcn@latest add @transition-kit/status-button

Usage

import { StatusButton } from "@/components/transitions/status-button";
<StatusButton
  onClick={() => saveProfile(values)}
  labels={{ pending: "Saving…", success: "Saved", error: "Couldn't save" }}
>
  Save changes
</StatusButton>
<StatusButton onClick={subscribe} icons={{ idle: <BellIcon /> }}>
  {(status) => (status === "success" ? "Subscribed" : "Subscribe")}
</StatusButton>
const [status, setStatus] = React.useState<StatusButtonStatus>("idle");
 
<StatusButton status={status} onStatusChange={setStatus} onClick={publish}>
  Publish
</StatusButton>;

API Reference

StatusButton

PropTypeDefaultDescription
status"idle" | "pending" | "success" | "error"-Controlled status to show. Sets data-status for styling each state, e.g. data-[status=success]:.
defaultStatus"idle" | "pending" | "success" | "error""idle"Initial status when uncontrolled.
onStatusChange(status: StatusButtonStatus) => void-Called with every status change.
onClick(event) => void | PromiseLike<unknown>-Returning a promise moves the status to pending, then success on resolve or error on reject. The rejection is caught; handle or report the error inside onClick.
resetAfternumber | false2000Milliseconds before success and error return to idle. false keeps the final status until you change it.
labelsPartial<Record<StatusButtonStatus, ReactNode>>{ success: "Done", error: "Failed" }Per-status labels merged over the defaults; ignored when children is a function.
iconsPartial<Record<StatusButtonStatus, ReactNode>>spinner, check and x iconsPer-status icons merged over the defaults. Pass null to remove a default icon, e.g. icons={{ pending: null }}.
variantsPartial<Record<StatusButtonStatus, ButtonVariant>>{ error: "destructive" }Per-status button variants merged over the defaults.
variant"default" | "destructive" | "outline" | "secondary" | "ghost" | "link""default"Base button variant when no per-status variant applies.
size"default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg""default"Button size passed to the underlying button.
childrenReactNode | (status: StatusButtonStatus) => ReactNode-Idle label, and pending label unless labels.pending is set. As a function, returns the label for every status and labels is ignored.