Copy Field

Read-only value you copy with one tap: the copy icon turns into a check and it confirms inline, no toast. Comes as a field, row or promo code, with masking; on phones it needs a clipboard package.

Preview

Installation

npx @lumioui/cli add copy-field

Usage

import { useCopy, CopyField, CopyButton } from "@/components/ui/copy-field/copy-field";
<CopyField />

Also exported: useCopy, CopyButton.

Examples

Backup codes

Two-factor recovery codes in a password vault.

Account details

A bank's "receive money" sheet.

Invite link

A running club's bring-a-friend screen.

Promo code ticket

A meal-kit offer shaped like a torn coupon.

API reference

CopyField

Prop Type Default
value* string

Copied verbatim.

—
display string

Shown instead of value (formatting only).

—
label string

Caption above the value (field / box) — also names the copy action for screen readers.

—
description string

Helper line under the field.

—
appearance "field" | "inline" | "box"

Default "field".

"field"
mono boolean

Monospaced value — codes, IBANs, keys.

false
groupSize number

Insert a space every n characters in the displayed value.

—
truncate "middle" | "tail" | "none"

Where a long value is cut. Default "middle" (keeps both ends of links and addresses).

"middle"
masked boolean

Hide all but the last maskVisible characters until revealed.

false
maskVisible number

Characters left visible while masked. Default 4.

4
copyLabel string "Copy"
copiedLabel string "Copied"
resetAfter number

ms the copied state lasts. Default 1800.

—
onCopy (value: string) => void —
highlight number

Bump to light the value as if it were just copied — e.g. every row lighting in turn when a "Copy all" button copies the set.

0
highlightDelay number

ms before a highlight lights the value (row stagger). Default 0.

0
disabled boolean false
className string —
valueClassName string —

CopyButton

Prop Type Default
value* string

Copied verbatim.

—
label string

Default "Copy".

"Copy"
copiedLabel string

Default "Copied".

"Copied"
variant "default" | "secondary"

"default" — accent/ink pill; "secondary" — neutral pill.

"secondary"
size "md" | "lg"

md 44 · lg 52. Default "md".

"md"
resetAfter number —
onCopy (value: string) => void —
disabled boolean false
announcement string

Spoken confirmation. Default "Copied".

—
confirmAfter number

ms between the copy and the button's confirmation — let what was copied light up first (pair with CopyField highlight). Default 0.

—
className string —