CopyButton
Copies a string and confirms it in place.
import
import { CopyButton } from '@joshicodes/cock';Copy
Behaviour
- Uses the asynchronous clipboard API, which browsers only allow from a real click on a secure origin. If the write is refused the button simply does not change.
API
Read out of the component sources at build time, so it matches the version you installed.
Every component also takes class, merged
through tailwind-merge so your utility wins.
Props of CopyButton
| Prop | Type | Default |
|---|---|---|
value required The text that ends up on the clipboard. | string | — |
label | string | 'Copy' |
copiedLabel | string | 'Copied' |
iconOnly Icon only; the label becomes the accessible name. | boolean | false |
variant | ButtonVariant | 'outline' |
size | ButtonSize | — |
class | string | — |
Events of CopyButton
| Event | Type | Default |
|---|---|---|
oncopy | (value: string) => void | — |