Copy underline
The value itself is the control. A dashed underline marks the text as copyable, which suits a reference shown in full inside a sentence or a table row.
Reach for it
Making a piece of visible text itself copyable, in place.
Not for
A value with no visible text, or one long enough to need its own control.
Inside a sentence
The visible text can be shortened while the copied value stays complete, so a reader sees a readable IBAN and pastes the real one.
Mandate was signed on 4 March.
Inside a row that navigates
Copying must not open the row. The component stops the click from reaching the row underneath, which is the case that makes this worth a component rather than a click handler.
| Reference | Debtor |
|---|---|
| Mooncard SAS | |
| Acme SAS |
API reference
CopyUnderline
| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode | - | What the user reads. Any content, since the value is passed separately. |
| value* | string | - | The text written to the clipboard. |
| copyLabel* | string | - | Tooltip at rest, e.g. "Click to copy". |
| copiedLabel* | string | - | Tooltip during the confirmation, e.g. "Copied". |
| data-testid | string | - | Names the element for a test. Never rendered, never announced. |
| layout | 'block' | 'inline' | block | |
| croppedLabel | string | - | Tooltip at rest while the text is cropped. Defaults to `value`. A cropped value has nowhere else to be read in full, so the tooltip carries it instead of the instruction. Text that fits keeps `copyLabel`, because repeating a value the reader already sees tells them nothing. |
| onCopyError | (error: unknown) => void | - | See CopyButton: a clipboard write can fail and the package cannot say so. |