Open levithomason opened 5 years ago
It is common in UI to have a button that copies content to the clipboard. Currently, users need to repeatedly implement this behavior.
A copy prop could be applied to component where it makes sense.
copy
<Button content='Click to copy' copy />
The prop could allow configuring the message shown on success/failure as well as the timeout:
<Button content='Click to copy' copy={{ success: 'Coped!', failure: "Couldn't Copy", timeout: 1000, }} />
Could be achieved as a utility component:
<CopyToClipboard as={Button} /> // or <CopyToClipboard> {() => ...} </CopyToClipboard>
Uses cases to consider:
Also, we can consider having a variant of input with the copy button.
Making the success/failure texts a required prop (instead of providing defaults) would force the developers to think about i18n.
Feature Request
Problem description
It is common in UI to have a button that copies content to the clipboard. Currently, users need to repeatedly implement this behavior.
Proposed solution
Pseudo Code Ideas
A
copy
prop could be applied to component where it makes sense.The prop could allow configuring the message shown on success/failure as well as the timeout:
Could be achieved as a utility component:
Uses cases to consider: