Copy Field

A read-only monospace value with a copy button.

Invite link

Installation

  1. Add the registryOnce per project
  2. Add copy-field

Usage

Long values scroll sideways. The button confirms the copy, including to screen readers.

Examples

Without a label

Leave out label when the context makes it clear.

Copying on click

copyOnClick copies when anywhere in the row is clicked, as long as no text in it is selected. The button still copies from the keyboard.

Confirming a copy

onCopy runs after the value is copied, such as to show a toast.

Install

Copy button

To copy a value shown some other way, use Copy Button on its own.

Props

CopyField takes the props of a <div>.

CopyField