---
layout: ~/layouts/MdxDocLayout.astro
title: "Clipboard Text"
description: "A text component with a copy-to-clipboard button."
sourceFile: "components/clipboard-text"
---

import ComponentExample from "~/components/docs/ComponentExample.astro";
import ComponentSection from "~/components/docs/ComponentSection.astro";
import Heading from "~/components/docs/Heading.astro";
import PropsTable from "~/components/docs/PropsTable.astro";
import {
  ClipboardTextBasicDemo,
  ClipboardTextShortDemo,
  ClipboardTextApiKeyDemo,
  ClipboardTextAlternateTextToCopyDemo,
  ClipboardTextLongDemo,
  ClipboardTextWithTooltipDemo,
} from "~/components/demos/ClipboardTextDemo";

{/* Hero Demo */}

<ComponentSection>
  <ComponentExample demo="ClipboardTextBasicDemo">
    <ClipboardTextBasicDemo client:visible />
  </ComponentExample>
</ComponentSection>

{/* Installation */}

<ComponentSection>
  <Heading level={2}>Installation</Heading>
  <Heading level={3}>Barrel</Heading>

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

<Heading level={3}>Granular</Heading>

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

</ComponentSection>

{/* Usage */}

<ComponentSection>
  <Heading level={2}>Usage</Heading>

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

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

</ComponentSection>

{/* Examples */}

<ComponentSection>
  <Heading level={2}>Examples</Heading>

<Heading level={3}>Short Text</Heading>
<ComponentExample demo="ClipboardTextShortDemo">
  <ClipboardTextShortDemo client:visible />
</ComponentExample>

<Heading level={3}>API Key</Heading>
<ComponentExample demo="ClipboardTextApiKeyDemo">
  <ClipboardTextApiKeyDemo client:visible />
</ComponentExample>

<Heading level={3}>Copy Alternate Text</Heading>
<ComponentExample demo="ClipboardTextAlternateTextToCopyDemo">
  <ClipboardTextAlternateTextToCopyDemo client:visible />
</ComponentExample>

<Heading level={3}>Long Text</Heading>
<ComponentExample demo="ClipboardTextLongDemo">
  <ClipboardTextLongDemo client:visible />
</ComponentExample>

<Heading level={3}>With Tooltip</Heading>
<p>Shows "Copy" tooltip on hover, "Copied!" toast on click.</p>
<ComponentExample demo="ClipboardTextWithTooltipDemo">
  <ClipboardTextWithTooltipDemo client:visible />
</ComponentExample>

</ComponentSection>

{/* API Reference */}

<ComponentSection>
  <Heading level={2}>API Reference</Heading>
  <PropsTable component="ClipboardText" />
</ComponentSection>
