SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

copyFeedback

Confirms a copy on the button that made it.

tsx
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

typescript
copyFeedback(copiedLabel: string): MixinDescriptor<HTMLButtonElement>

Returns a mixin descriptor for the copy button's mix prop.

Parameters

ParameterTypeRequiredDescription
copiedLabelstringYesThe confirmation a screen reader announces, such as "Copied".

Examples

tsx
<button commandfor="code" command={COPY_COMMAND} mix={[copyToClipboard(), copyFeedback(t("copied"))]}>
	<CopyIcon />
	<span role="status" mix={[visuallyHidden()]} />
</button>

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.

typescript
const COPIED_ATTRIBUTE = "data-copied"
@sdxc/ui

Can’t find it? Contact us