Ark Logo

Clipboard

A component to copy text to the clipboard

Anatomy

To set up the Clipboard correctly, you'll need to understand its anatomy and how we name its parts.

Each part includes a data-part attribute to help identify them in the DOM.

Examples

Learn how to use the Clipboard component in your project. Let's take a look at the most basic example:

<script setup lang="ts">
import { Clipboard } from '@ark-ui/vue'
import { CheckIcon, ClipboardCopyIcon } from 'lucide-vue-next'
</script>

<template>
  <Clipboard.Root value="https.//ark-ui.com">
    <Clipboard.Label>Copy this link</Clipboard.Label>
    <Clipboard.Control>
      <Clipboard.Input />
      <Clipboard.Trigger>
        <Clipboard.Indicator>
          <ClipboardCopyIcon />
          <template #copied>
            <CheckIcon />
          </template>
        </Clipboard.Indicator>
      </Clipboard.Trigger>
    </Clipboard.Control>
  </Clipboard.Root>
</template>

API Reference

Root

PropDefaultType
asChildfalse
boolean

id
string

The unique identifier of the machine.

ids
Partial<{ root: string; input: string; label: string }>

The ids of the elements in the clipboard. Useful for composition.

timeout3000
number

The timeout for the copy operation

value
string

The value to be copied to the clipboard

EmitEvent
statusChange
[details: CopyStatusDetails]

The function to be called when the value is copied to the clipboard

Data AttributeValue
[data-scope]clipboard
[data-part]root
[data-copied]Present when copied state is true

Control

PropDefaultType
asChildfalse
boolean

Data AttributeValue
[data-scope]clipboard
[data-part]control
[data-copied]Present when copied state is true

Indicator

PropDefaultType
asChildfalse
boolean

Input

PropDefaultType
asChildfalse
boolean

Data AttributeValue
[data-scope]clipboard
[data-part]input
[data-copied]Present when copied state is true
[data-readonly]Present when read-only

Label

PropDefaultType
asChildfalse
boolean

Data AttributeValue
[data-scope]clipboard
[data-part]label
[data-copied]Present when copied state is true

Trigger

PropDefaultType
asChildfalse
boolean

Data AttributeValue
[data-scope]clipboard
[data-part]trigger
[data-copied]Present when copied state is true