Reference
CopyButton
A button that copies value: to the clipboard, says Copied for a moment, and tells a screen reader so.
CopyButton(_ label: String, value: String or Number, copied: String)
Since 6.2.0
label
copied
https://ledger.example.com/invite/42
Example
Row(gap: .sm, align: .center) {
Code("https://ledger.example.com/invite/42")
CopyButton("Copy link", value: "https://ledger.example.com/invite/42", copied: "Link copied")
}
With its own words
CopyButton(value: "wf init my-site -t static")
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
label | String (positional) | Copy | Its words |
value: | String or Number (required) | — | What it copies, read when it is pressed; a value that reads state copies what it holds then |
copied: | String | Copied | What it says for 1.6 s once it has copied, also announced to a screen reader |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
No flags of its own.
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-btn wf-copy-button, stable across releases, so a stylesheet may target it.