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.
Call copy from the trigger. copied is true for a second after the copy.
Use timeout to change how long copied lasts, in milliseconds.
Show a value next to a button that copies it. The button text says when it is done.
| Attribute | Description | Type | Accepted values | Default |
|---|---|---|---|---|
| value | text copied to the clipboard | string | - | - |
| timeout | milliseconds that copied stays true after a copy | number | - | 1000 |
| children | function that returns the trigger | ({ copied, copy }) => ReactNode | - | - |
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.