About
A button that morphs its label and icon through idle, loading, success and error states, with the text rolling in letter by letter and the button width easing to fit.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Stateful Button to your project and fits it to your theme.
Code
How Stateful Button is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import StatefulButton from "@/components/ui/button-stateful";
import { useState } from "react";
type DemoState = "idle" | "loading" | "success" | "error";
export default function StatefulButtonDemo() {
const [state, setState] = useState<DemoState>("idle");
const run = () => {
setState("loading");
window.setTimeout(() => {
setState("success");
window.setTimeout(() => setState("idle"), 1600);
}, 1400);
};
return (
<div className="flex min-h-[320px] w-full items-center justify-center">
<StatefulButton
state={state}
onClick={run}
loadingText="Saving"
successText="Saved"
errorText="Try again"
>
Save changes
</StatefulButton>
</div>
);
}















