Use ClipboardCopy
to copy element text content or input values to the clipboard.
Always set an accessible label to help the user interact with the component.
Name | Type | Default | Description |
---|---|---|---|
aria-label | String | N/A | String that will be read to screenreaders when the component is focused |
value | String | nil | Text to copy into the users clipboard when they click the component. |
for | String | N/A | Element id from where to get the copied value. |
system_arguments | Hash | N/A | System arguments |
<%= render(Primer::Beta::ClipboardCopy.new(value: "Text to copy", "aria-label": "Copy text to the system clipboard")) %>
<%= render(Primer::Beta::ClipboardCopy.new(value: "Text to copy")) do %>Click to copy!<% end %>
<%= render(Primer::Beta::ClipboardCopy.new(for: "blob-path", "aria-label": "Copy text to the system clipboard")) %><div id="blob-path">src/index.js</div>