Mark Yo

Stateful Button

Buttons

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>
  );
}

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    72
  • Pricing Table

    Pricing Table

    33
  • Bento Grid

    Bento Grid

    22
  • Approval Queue

    Approval Queue

    20
  • Expandable Tabs

    Expandable Tabs

    19
  • Image Gallery

    Image Gallery

    17
  • Wallet Card

    Wallet Card

    15
  • Feature Section

    Feature Section

    12

More in Buttons

View all
  • Button

    Button

    166
  • Texture Button

    Texture Button

    121
  • Button

    Button

    21
  • Figma File Button

    Figma File Button

    39
  • Native Button

    Native Button

    12
  • Button

    Button

    88
  • HeroUI Button Group

    HeroUI Button Group

    11
  • Great UI Button

    Great UI Button

    19