Components
- Accordion
- Add to Cart
- Animated List
- Carousel
- Collapsible Sidebarnew
- Dynamic Island
- Expandable Cardnew
- Expanding Searchnew
- Filter Grid
- Kanban Board
- Layout Switcher
- Morphing Popover
- Number Flip
- Page Transition
- Product Gallery
- Segmented Control
- Sortable Table
- Stack Navigator
- Status Button
- Step Wizard
- Tabs
- Text Morphnew
- Theme Mode Switch
- Theme Morph Button
- Theme Toggle Button
- Theme Toggle Switch
- Theme Transition
- Toast Stacknew
Visible to everyone in your workspace.
acme-web
main · a1f9c2e · 2 minutes ago
Installation
$ pnpm dlx shadcn@latest add @transition-kit/status-buttonUsage
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
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
resetAfter | number | false | 2000 | Milliseconds before success and error return to idle. false keeps the final status until you change it. |
labels | Partial<Record<StatusButtonStatus, ReactNode>> | { success: "Done", error: "Failed" } | Per-status labels merged over the defaults; ignored when children is a function. |
icons | Partial<Record<StatusButtonStatus, ReactNode>> | spinner, check and x icons | Per-status icons merged over the defaults. Pass null to remove a default icon, e.g. icons={{ pending: null }}. |
variants | Partial<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. |
children | ReactNode | (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. |