CopyButton
moleculesCopies a string to the clipboard and flips to a transient "Copied" state, announced to screen readers.
API keys and install command
text is the string copied; box="sm" makes an icon-only square beside a code value.
- Publishable key
- pk_live_4f8a0c21e9b7d3f9a
- Secret key
- sk_live_••••••••••••c21e
- Webhook URL
- https://hooks.example.dev/in/7d3f9a
npm i @dorsk/tsumikit
Variants and boxes
variant picks the Button chrome; box="xs|sm|md|lg" makes a square icon-only control; showLabel overrides.
Copied feedback and labels
copiedLabel and resetMs tune the confirmation; hitArea="compact" drops the touch slab in dense rows; sound={false} silences one instance.
- 7f3c9e2 Tooltip: hovercard mode with persist-on-hover
- b41d08a Menu: control rows join arrow navigation
- e9a7c55 Toaster: move into the topmost modal while one is open
Micro-interactions
data-fx-copy on any ancestor: "burst" (default) springs the check in a ring of sparks, "tick" draws the tick and rolls the label, "none" swaps plainly.
data-fx-copy="burst"
data-fx-copy="tick"
data-fx-copy="none"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
text required | string | — | The string to copy. |
label | string | 'Copy' | |
copiedLabel | string | 'Copied' | |
variant | 'default' | 'primary' | 'ghost' | 'danger' | 'ghost' | |
showLabel | boolean | — | Defaults to true, or false when `box` makes it icon-only. |
box | 'xs' | 'sm' | 'md' | 'lg' | — | Shared square box scale (`--box-xs/sm/md/lg`): a square icon-only copy control. |
hitArea | 'auto' | 'compact' | 'auto' | |
resetMs | number | 1500 | |
sound | boolean | true | Play UI sounds when enabled globally; false silences this instance. |
class | string | '' |