Copy Button

Copies a text to the clipboard and tells you when it is done. It draws nothing by itself: you return the trigger, so it works with a Button, a link or an icon.

General

Call copy from the trigger. copied is true for a second after the copy.

Timeout

Use timeout to change how long copied lasts, in milliseconds.

API key

Show a value next to a button that copies it. The button text says when it is done.

APIs

CopyButton.Props

AttributeDescriptionTypeAccepted valuesDefault
valuetext copied to the clipboardstring--
timeoutmilliseconds that copied stays true after a copynumber-1000
childrenfunction that returns the trigger({ copied, copy }) => ReactNode--

Accessibility

The component adds no element, so the trigger you return carries the semantics. Use a real button, and change its text when copied is true so the new state is clear.

Edit this page on GitHub