-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the option to copy label/text to clipboard. #1055
Comments
Hey @mathieu-fournier, I do not think this necessarily belongs in iTwinUI, considering how easy it is to implement using |
Typography components are a bit too level for this imo. Already not a fan of the All that to say, a prop is not the right abstraction, and if we were to add this, it would likely be a new component. I will leave this issue open, but in the meantime, here's a sandbox you can base your implementation on: codesandbox.io/s/copy-button-example-itwinui-pncqud (copy doesn't work in iframe, so preview in new window: https://pncqud.csb.app/) |
A prop would be awesome for usage simplicity, but I agree that it would definitely be more difficult to implement. I created a component that does the trick. https://codesandbox.io/s/copy-button-example-itwinui-forked-e96tz1?file=/src/CopyTextToClipboard.jsx |
One thing I should point out is that for better accessibility, you should consider using visually-hidden styles for hiding the button, and unhiding when hovered or focused. You can read more here: https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html I've updated my sandbox to show how that would work: |
Feature
It might be a ggod addition to have the possibility to copy text to the clipboard with a single mouse press.
Components would enable it by passing something like isCopyToClipboardEnabled = true.
Examples
In the Azure portal it's presented like this.
When hovering on the text, the files icon appear.
When hovering the files icon, the tooltip shows-up.
The text was updated successfully, but these errors were encountered: