Copy button

Two ways to copy a value, with the same feedback: the copy icon shrinks into a check, the tooltip says Copied, and screen readers hear it. CopyButton is a Button; CopyField is the value itself.

Playground

Click it, then paste somewhere.

Variant
Size
<CopyButton value={mmsi} />

Next to a value

Icon only, small and ghost, right after what it copies. The tooltip names what will be copied.

MMSI 259040560
Position 60.3913° N, 5.3221° E

Copy field

The value is the button. Hover it and the copy icon slides in; click and it turns into a check. Tap it on a phone and the check slides in on its own.

Variant
<CopyField value={project.reference} />

In a meta line

Plain fields read as part of the line until hovered: the project number and the customer's reference.

Vestland Marin AS

Which one

  • The value is already on screen and short: make it a CopyField, so the thing you see is the thing you click.
  • The value is long, hidden, or sits in a label and value pair: a CopyButton after it, icon only, ghost and xs.
  • A copy action among other buttons, in a toolbar or a dialog footer: a CopyButton.
  • Keys and hashes read character by character get mono. IDs and references don't.