Cnippet

Button

Buttons 5

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 { MenuIcon, XIcon } from "lucide-react";
import { useState } from "react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/cnippet-button";

export default function ButtonMenuToggle() {
  const [open, setOpen] = useState(false);

  return (
    <Button
      aria-expanded={open}
      aria-label={open ? "Close menu" : "Open menu"}
      onClick={() => setOpen((v) => !v)}
      size="icon"
      variant="outline"
    >
      <span className="relative flex size-4 items-center justify-center">
        <MenuIcon
          aria-hidden="true"
          className={cn(
            "absolute size-4 transition-all duration-200",
            open
              ? "rotate-90 scale-75 opacity-0"
              : "rotate-0 scale-100 opacity-100",
          )}
        />
        <XIcon
          aria-hidden="true"
          className={cn(
            "absolute size-4 transition-all duration-200",
            open
              ? "rotate-0 scale-100 opacity-100"
              : "-rotate-90 scale-75 opacity-0",
          )}
        />
      </span>
    </Button>
  );
}

Dependencies

More by Cnippet

View all
  • Team

    Team

    1.3K
  • Davincho Hero-1

    Davincho Hero-1

    686
  • Aero Hero-3

    Aero Hero-3

    576
  • Features

    Features

    514
  • Random Letter Swap Navigation

    Random Letter Swap Navigation

    496
  • Services with Animated Hover Modal

    Services with Animated Hover Modal

    468
  • Blogs

    Blogs

    397
  • Aero Hero-1

    Aero Hero-1

    363

More in Buttons

View all
  • Texture Button

    Texture Button

    97
  • Button

    Button

    5
  • Button Group

    Button Group

  • Eclipse Button

    Eclipse Button

    39
  • Button

    Button

    4
  • HeroUI Button Group

    HeroUI Button Group

  • App Store Button

    App Store Button

    458
  • Base Button

    Base Button

    4