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.4K
  • Hero

    Hero

    1.3K
  • Profile Card

    Profile Card

    765
  • Roadmap Card

    Roadmap Card

    572
  • Hero

    Hero

    473
  • Glassmorphism Profile Card

    Glassmorphism Profile Card

    458
  • Highlight Card

    Highlight Card

    429
  • Product Card

    Product Card

    386

More in Buttons

View all
  • Button

    Button

    5
  • Texture Button

    Texture Button

    97
  • Button Group

    Button Group

  • Eclipse Button

    Eclipse Button

    39
  • Button

    Button

    4
  • HeroUI Button Group

    HeroUI Button Group

  • Base Button

    Base Button

    4
  • App Store Button

    App Store Button

    458