Actions Core Stable

CopyButton

Button preset wired to the clipboard, swapping its icon and label to a success skin for a moment after a successful copy

Preview

Installation

pnpm add fancy-ui-svelte
import { CopyButton } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { CopyButton } from 'fancy-ui-svelte';
</script>

<CopyButton />

Examples

Basic Usage

An outline button that copies a value on click.

Icon Only

Drops the visible label into aria-label for a toolbar.

Custom Labels

Overrides the idle and copied label text.

Variants

Four Button variants used as the idle skin.

Props

PropTypeDefaultDescription
value *string-The text written to the clipboard on activation
label string"Copy"Idle label
copiedLabel string"Copied"Label shown for resetMs after a successful copy
resetMs number2000How long the copied state holds before reverting, in milliseconds
variant ButtonVariant"outline"Passed straight through to the underlying Button
size ButtonSize"md"Passed straight through to the underlying Button
disabled booleanfalseDisables the button and blocks the copy
iconOnly booleanfalseDrops the visible label, moving it to aria-label instead
onCopy (value: string, ok: boolean) => void-Called with the value and whether the write actually succeeded
class string-Additional CSS classes
ref HTMLButtonElement | HTMLAnchorElement | nullnullBindable element reference, matching Button's own ref type
sound booleanfalsePlays the copy cue on a successful copy and error on a failed one, once the user has enabled sound

Slots

SlotDescription
childrenOverrides the default icon + label content