Skip to content

Copy field

Pro

A read-only value with a copy button and its own confirmation. Not an M3 component (@windmorph/react-pro).

import { CopyField } from '@windmorph/react-pro';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Props

By name or description, across the 21 props below

CopyField 21 props

  • valuetype stringRequired

    The value shown, and copied unless copyValue is set.

  • copyValuetype stringdefault value

    What is copied, when it differs from what is shown.

  • supportingTexttype ReactNode

    Help text below the field.

  • varianttype "filled" | "outlined"default the core TextField's

    The field's style.

  • densitytype 0 | -1 | -2 | -3

    The field's own density; left out, it inherits the theme's.

  • disabledtype booleandefault false

    Turns off the field and its button.

  • confirmationDurationtype numberdefault 2000

    How long the confirmation shows, ms.

  • copyIcontype ReactNodedefault Material Symbols content_copy

    The button's icon at rest.

  • copiedIcontype ReactNodedefault Material Symbols check

    The button's icon once copied.

  • errorIcontype ReactNodedefault Material Symbols error

    The button's icon when copying failed.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • inputReftype Ref<HTMLInputElement>

    Ref to the text box.

  • idtype string

    The text box's id.

  • labeltype ReactNode

    The visible name above the value.

    One of label or aria-label is required.

Events

  • onCopytype ((text: string) => void)

    Called with the text once it is on the clipboard.

  • onCopyErrortype ((error: unknown) => void)

    Called when the text couldn't be copied.

Text

  • labelstype Partial<CopyFieldLabels>

    Words it shows or announces. A LabelsProvider sets them for the whole app.

  • aria-labeltype string

    One of label or aria-label is required.

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

  • Filled and outlined (variant)

    Built

    Variant · Variants

  • Copying something other than what shows (copyValue)

    Built

    Configuration · Masked

Theming & tokens

Set the tokens below on the field or any ancestor. The field and button keep the core's own tokens. Style each part with classNames: button, icon, status, …every key of the core TextField's classNames.

CopyField tokens
VariableDefaultPaints
--wm-copy-field-copied-icon-colorvar(--md-sys-color-primary)The icon once the value is copied.
--wm-copy-field-failed-icon-colorvar(--md-sys-color-error)The icon when copying failed.
--wm-copy-field-icon-size24pxThe size of the icon.
--wm-copy-field-icon-fade-durationvar(--md-sys-motion-spring-effects-fast-duration)How long a new icon takes to fade in; it stays under reduced motion.
--wm-copy-field-icon-fade-easingvar(--md-sys-motion-spring-effects-fast-easing)The easing of the icon’s fade.