@cloudflare/kumo
0c239dd2
import { ClipboardText } from "@cloudflare/kumo";

export function ClipboardTextBasicDemo() {
  return <ClipboardText text="0c239dd2" />;
}

Installation

Barrel

import { ClipboardText } from "@cloudflare/kumo";

Granular

import { ClipboardText } from "@cloudflare/kumo/components/clipboard-text";

Usage

import { ClipboardText } from "@cloudflare/kumo";

export default function Example() {
  return <ClipboardText text="Copy this text" />;
}

Accessibility and localization

ClipboardText includes Kumo-owned strings for the icon-only copy button, tooltip, and copied status. Pass these user-facing and assistive labels in your consumer’s language.

  • labels.copyAction names the copy button for assistive technology. It defaults to “Copy to clipboard”.

  • tooltip.text shows the hover tooltip when tooltip mode is enabled. It defaults to “Copy”.

  • tooltip.copiedText shows the copied toast in tooltip mode and announces the copied status. It defaults to “Copied”.

<ClipboardText
  text="sk_live_***********"
  textToCopy="sk_live_51H8_abc123"
  labels={{ copyAction: t("clipboard.copyAction") }}
  tooltip={{
    text: t("clipboard.copy"),
    copiedText: t("clipboard.copied"),
  }}
/>

The generated props table focuses on Kumo-owned props and does not enumerate inherited ARIA/native attributes. Use the localization props above for ClipboardText’s built-in controls.

Examples

Short Text

abc123
import { ClipboardText } from "@cloudflare/kumo";

export function ClipboardTextShortDemo() {
  return <ClipboardText text="abc123" />;
}

API Key

sk_live_51H8...
import { ClipboardText } from "@cloudflare/kumo";

export function ClipboardTextApiKeyDemo() {
  return <ClipboardText text="sk_live_51H8..." />;
}

Copy Alternate Text

sk_live_***********
import { ClipboardText } from "@cloudflare/kumo";

export function ClipboardTextAlternateTextToCopyDemo() {
  return (
    <ClipboardText
      text="sk_live_***********"
      textToCopy="sk_live_51H8_abc123"
    />
  );
}

Long Text

https://example.com/very/long/url/path
import { ClipboardText } from "@cloudflare/kumo";

export function ClipboardTextLongDemo() {
  return <ClipboardText text="https://example.com/very/long/url/path" />;
}

With Tooltip

Shows “Copy” tooltip on hover, “Copied!” toast on click.

npx kumo add button
import { ClipboardText } from "@cloudflare/kumo";

/** With tooltip on hover showing "Copy", and anchored toast on click showing "Copied" */
export function ClipboardTextWithTooltipDemo() {
  return (
    <ClipboardText
      text="npx kumo add button"
      tooltip={{ text: "Copy", copiedText: "Copied!", side: "top" }}
    />
  );
}

API Reference

PropTypeDefaultDescription
size"sm" | "base" | "lg""lg"Size of the clipboard text field. - `"sm"` — Small clipboard text for compact UIs - `"base"` — Default clipboard text size - `"lg"` — Large clipboard text for prominent display
text*string-The text to display and copy to clipboard.
textToCopystring-If provided, this text will be copied to clipboard instead of the `text` prop.
classNamestring-Additional CSS classes merged via `cn()`.
tooltipobject-Tooltip config. Shows tooltip on hover, anchored toast on click.
labelsobject-Accessible labels for i18n.