copyFeedback
Confirms a copy on the button that made it.
import { copyFeedback } from "@sdxc/ui/docs";Usage
Marks its host button as copied after every successful copyToClipboard write and
writes copiedLabel into the [role="status"] element inside it, which a screen reader
announces; both clear after two seconds, and a second copy restarts the clock.
Signature
copyFeedback(copiedLabel: string): MixinDescriptor<HTMLButtonElement>Returns a mixin descriptor for the copy button's mix prop.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
copiedLabel | string | Yes | The confirmation a screen reader announces, such as "Copied". |
Examples
<button commandfor="code" command={COPY_COMMAND} mix={[copyToClipboard(), copyFeedback(t("copied"))]}>
<CopyIcon />
<span role="status" mix={[visuallyHidden()]} />
</button>Used with it
The events, constants and types its module publishes, each imported from @sdxc/ui/docs too.
Constant
COPIED_ATTRIBUTE
Attribute the button carries while it confirms a copy.
const COPIED_ATTRIBUTE = "data-copied"