Cnippet

Button

Buttons

About

A polymorphic button built on Base UI's useRender. Ships 8 visual variants (default, secondary, outline, ghost, link, destructive, destructive-outline) and a full set of sizes including icon sizes (xs–xl). Has a built-in loading state that overlays an inline spinner and hides the label, a render prop for rendering as any element or as a child, and focus-visible / pressed styling out of the box.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Button to your project and fits it to your theme.

Code

How Button is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { CheckIcon, CloudUploadIcon } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/ui/cnippet-button";

type State = "idle" | "loading" | "success";

export default function ButtonLoading() {
  const [state, setState] = useState<State>("idle");

  const handleClick = () => {
    if (state !== "idle") return;
    setState("loading");
    setTimeout(() => {
      setState("success");
      setTimeout(() => setState("idle"), 2000);
    }, 1800);
  };

  return (
    <Button
      disabled={state === "loading"}
      loading={state === "loading"}
      onClick={handleClick}
      variant={state === "success" ? "outline" : "default"}
    >
      {state === "success" ? (
        <>
          <CheckIcon className="size-4 text-emerald-500" />
          Saved
        </>
      ) : (
        <>
          <CloudUploadIcon className="size-4" />
          {state === "loading" ? "Saving…" : "Save Changes"}
        </>
      )}
    </Button>
  );
}

Dependencies

More by Cnippet

View all
  • Team

    Team

    1.3K
  • Davincho Hero-1

    Davincho Hero-1

    683
  • Aero Hero-3

    Aero Hero-3

    558
  • Features

    Features

    510
  • Random Letter Swap Navigation

    Random Letter Swap Navigation

    487
  • Services with Animated Hover Modal

    Services with Animated Hover Modal

    465
  • Blogs

    Blogs

    396
  • Aero Hero-1

    Aero Hero-1

    356

More in Buttons

View all
  • Button

    Button

    14
  • Button

    Button

    34
  • Texture Button

    Texture Button

    92
  • Button Save

    Button Save

    46
  • Button

    Button

    64
  • Button Group

    Button Group

    3
  • App Store Button

    App Store Button

    454
  • Notification Button

    Notification Button

    103