Copy to clipboard button

A button that copies text to the user's clipboard.
Properties
clipboardText
tooltipText
icon
Example
Source Code
Installation
"use client";

import React from "react";
import { CopyToClipboardButton } from "@/subframe/components/CopyToClipboardButton";

function CopyToClipboardButtonExample() {
  return (
    <CopyToClipboardButton
      clipboardText=""
      tooltipText="Copy to clipboard"
      icon="FeatherClipboard"
    />
  );
}

export default CopyToClipboardButtonExample;

Props

Copy to clipboard button
Prop
Type
Default
Additional info
clipboardText
string
""
The text to be copied to the clipboard
tooltipText
string
"Copy to clipboard"
icon
IconName
"FeatherClipboard"
onCopy
() => void
Handler called when user copies the text.

Examples

Basics

Use clipboardText prop for the text that is copied on click, tooltipText for the tooltip copy.

Confirmation message

Use onCopy prop to show feedback to user after copying.