CopyInput
A readonly TextInput combined with a Button to copy its content to the clipboard. Use to copy text such as urls, ids, or keys.
Default
CopyInput
renders a TextInput
with a Button
that copies its value to the clipboard.
Editable example
Best practices
- Use a label that accurately describes the text inside the input. E.g. instead of using
Copy
, describe the content withPublic link
. CopyInput
is great for giving a preview of what will actually be copied to the user's clipboard. If this isn't important, or if there is limited available space, using the could be a better fit.
Hidden label
The label can be visually hidden for situations where it's visually clear what the input is for based on its context.
Editable example
Size
CopyInput
accepts s
, m
, or l
sizes. The default size is m
. Choose a size that is appropriate given the surrounding elements. E.g. if in the same context there are other small sized controls, use a small sized CopyInput
.
Editable example
Button content
If more context is needed for the copy button, its text can be changed using the buttonContent
prop.
Editable example
Accessibility
- Always provide a
label
. For situations where the label is inferred visually, thelabelHidden
prop will hide it visually but keep the label readable by assistive technology.