useCopyToClipboard

Hook

Provides a copy function and a copied state that auto-resets after 2 seconds.

npx arupui add use-copy-to-clipboard

Usage

use-copy-to-clipboard.tsx
import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"

function CopyButton({ text }: { text: string }) {
  const [copied, copy] = useCopyToClipboard()

  return (
    <button onClick={() => copy(text)}>
      {copied ? "Copied!" : "Copy"}
    </button>
  )
}

Returns

[copied: boolean, copy: (text: string) => Promise<void>]
Theme Editor

Theme

Radius0.5rem
Letter Spacing0em

Colors

light