SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

copyPermalink

Why JS: a copy-link button writes a record's URL to the clipboard, which only script reaches.

tsx
import { copyPermalink } from "@sdxc/ui/app";

Usage

Writes permalink, resolved against the page's URL so a relative path copies as a full address, to the clipboard on every press. A successful write sets data-copied on the button and writes copiedLabel into its [role="status"] element for two seconds.

Signature

typescript
copyPermalink(permalink: string, copiedLabel: string): MixinDescriptor<HTMLButtonElement>

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

Parameters

ParameterTypeRequiredDescription
permalinkstringYesThe record's URL, absolute or relative to the page.
copiedLabelstringYesWhat a screen reader announces once the link is copied.

Examples

tsx
<button type="button" mix={[copyPermalink("/monitors/42", t("linkCopied"))]}>
	<LinkIcon /><span role="status" mix={[visuallyHidden()]} />
</button>
@sdxc/ui

Can’t find it? Contact us