PXD
v0.2.1-dev

Copy Button

A button that copies a given string to the clipboard and provides feedback when copied.

Default

CopyButton extends the Button component.

<template>
  <PCopyButton content="lorem" />
</template>

Variant

<template>
  <PStack>
    <PCopyButton content="lorem" variant="default" />
    <PCopyButton content="lorem" variant="primary" />
    <PCopyButton content="lorem" variant="success" />
    <PCopyButton content="lorem" variant="warning" />
    <PCopyButton content="lorem" variant="error" />
    <PCopyButton content="lorem" variant="ghost" />
  </PStack>
</template>

With label

<template>
  <PCopyButton content="lorem" variant="default">
    <span>
      Click to copy
    </span>
  </PCopyButton>
</template>

Props

NameTypeDefaultDescription
contentComponentText | ((event: PointerEvent) => ComponentText)-Text to copy, or a function that receives the click event

Events

NameTypeDescription
copy(content: string, event: PointerEvent) => voidEmitted after the text has been copied to the clipboard.
error(error: unknown, event: PointerEvent) => voidEmitted when copying fails after both the Clipboard API and the fallback failed.

Source

Source