Copy button
Copy button component that copies a text to the clipboard, confirms it and announces it to screen readers, with an icon only variant.
How to use it
Run npx @blossomui/react add copy-button, or copy src/components/UI/CopyButton/CopyButton.tsx into your React project and import it.
import { CopyButton } from './components/ui/CopyButton'Props
CopyButtonProps
| Prop | Type | Description |
|---|---|---|
| text (required) | string | The text that goes to the clipboard. |
| label | string | Text of the button, or the accessible name when it is `icon` only. |
| copiedLabel | string | Text shown for a moment after copying. |
| timeout | number | Milliseconds the copied state lasts. |
| variant | 'button' | 'icon' | `button` shows the text, `icon` only the icon. |
| size | 'sm' | 'md' | 'lg' | |
| color | string | Accent color of the copied state: any CSS color. Without it the component uses `--blossom-accent`. |
| onCopy | (text: string) => void | Called after the text was copied. |
| icon | ReactNode | Custom icons: the one shown before copying and the one shown after. |
| copiedIcon | ReactNode | |
| className | string |