Clipboard

stable 0.4 kB
<hkCopy>

Copy with a confirmation state that reverts itself — and reports failure, because the Clipboard API is refused often enough that silence is a bug.

#directive#copy

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
hkCopystring''Text to write to the clipboard.
copyResetDelaynumber1600How long the confirmed state lasts.

Outputs

  • copiedEventEmitter<string>

    Emits the copied text on success.

  • copyFailedEventEmitter<Error>

    Emits when the browser refuses.

Keyboard

  • Enter / Space Copies from a focused host

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-copy-success#059669Confirmed state colour.

Accessibility

  • Success is announced through an aria-live region, so it is not conveyed by the tick alone.
  • Failure surfaces as a message — a permission-blocked clipboard must not look like success.

More in Utility