Copy field
ProA 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
CopyField 21 props
The value shown, and copied unless
copyValueis set.What is copied, when it differs from what is shown.
Help text below the field.
The field's style.
The field's own density; left out, it inherits the theme's.
Turns off the field and its button.
How long the confirmation shows, ms.
The button's icon at rest.
The button's icon once copied.
The button's icon when copying failed.
Ref to the outermost element.
Ref to the text box.
The text box's id.
The visible name above the value.
One of
labeloraria-labelis required.
Events
Called with the text once it is on the clipboard.
Called when the text couldn't be copied.
Text
Words it shows or announces. A
LabelsProvidersets them for the whole app.One of
labeloraria-labelis required.
Classes for the outermost element. Wins over the defaults via
cn().Classes for each part.
The icon inside the button.
The visually hidden status that announces the result.
The root element, merged with
className.The filled or outlined container around the label, input and icons.
The floating label.
The
<input>or<textarea>.The leading icon's 48px box.
The trailing icon's 48px box.
The prefix text before the input.
The suffix text after the input.
The helper text below the field.
The error message below the field.
The character counter below the field.
The built-in error icon.
The outlined field's border (a
<fieldset>, notched for the floated label).The filled field's active indicator, the line along the container's bottom.
Inline styles for the outermost element.
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.
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.
| Variable | Default | Paints |
|---|---|---|
--wm-copy-field-copied-icon-color | var(--md-sys-color-primary) | The icon once the value is copied. |
--wm-copy-field-failed-icon-color | var(--md-sys-color-error) | The icon when copying failed. |
--wm-copy-field-icon-size | 24px | The size of the icon. |
--wm-copy-field-icon-fade-duration | var(--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-easing | var(--md-sys-motion-spring-effects-fast-easing) | The easing of the icon’s fade. |