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.

Purpose

A read-only value with a copy button and its own confirmation, for invite links, identifiers and addresses. To let someone type, use a TextField.

Behaviour

  • The icon changes and the button's name changes, for confirmationDuration, and the result is announced. No snackbar is needed.
  • It copies with the Clipboard API, falls back to a selection on an insecure origin, and reports a failure through the failed state and onCopyError.
  • copyValue copies something other than value, such as the whole of a masked key.
  • Focus in the field selects its text.

When not to use

To let someone type, use a TextField.

See also

  • Text field: Filled or outlined text input with a floating label, icons, affixes, counter, error icon and a text area.
  • Snackbar: A brief message with an optional action and dismiss, queued through a host.