Berat Berkay Gökdemir

Code Snippet

Buttons 14

About

Code Snippet

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

Code

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

Usage.tsx

"use client";

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

interface CopyButtonProps {
  value: string;
}

export function CopyButton({ value }: CopyButtonProps) {
  const [hasCopied, setHasCopied] = useState(false);

  const copyToClipboard = async () => {
   // await navigator.clipboard.writeText(value);
    setHasCopied(true);
    setTimeout(() => setHasCopied(false), 2000);
  };

  return (
    <Button variant="ghost" size="icon" onClick={copyToClipboard}>
      {hasCopied ? (
        <CheckIcon className="h-4 w-4" color="green" />
      ) : (
        <CopyIcon className="h-4 w-4" />
      )}
      <span className="sr-only">Copy code</span>
    </Button>
  );
}

More by Berat Berkay Gökdemir

View all
  • AI Loader

    AI Loader

    1.3K
  • Hero

    Hero

    1.2K
  • Profile Card

    Profile Card

    743
  • Roadmap Card

    Roadmap Card

    568
  • Hero

    Hero

    466
  • Glassmorphism Profile Card

    Glassmorphism Profile Card

    435
  • Highlight Card

    Highlight Card

    425
  • Product Card

    Product Card

    375

More in Buttons

View all
  • Button Save

    Button Save

    46
  • Button

    Button

    20
  • Eclipse Button

    Eclipse Button

    5
  • Button

    Button

    32
  • Button

    Button

    6
  • Button

    Button

    14
  • Button Group

    Button Group

    37
  • Split Button

    Split Button

    32