Skip to content
UI

Clipboard

A component that allows users to copy text to the clipboard.

<script setup lang="ts">
import { Clipboard } from '@destyler-ui/vue'
</script>

<template>
  <Clipboard.Root value="https.//destyler.org">
    <Clipboard.Label>Copy this link</Clipboard.Label>
    <Clipboard.Control>
      <Clipboard.Input />
      <Clipboard.Trigger>
        <Clipboard.Indicator>
          <span class="i-tabler-copy" />
          <template #copied>
            <span class="i-tabler-check" />
          </template>
        </Clipboard.Indicator>
      </Clipboard.Trigger>
    </Clipboard.Control>
  </Clipboard.Root>
</template>
import { Clipboard } from '@destyler-ui/react'

export function Basic() {
  return (
    <Clipboard.Root value="https://destyler.org">
      <Clipboard.Label>Copy this link</Clipboard.Label>
      <Clipboard.Control>
        <Clipboard.Input />
        <Clipboard.Trigger>
          <Clipboard.Indicator copied={
            <span>Copied!</span>
          }
          >
            <span>Copy</span>
          </Clipboard.Indicator>
        </Clipboard.Trigger>
      </Clipboard.Control>
    </Clipboard.Root>
  )
}
import { Clipboard } from '@destyler-ui/solid/clipboard'
import { CheckIcon, ClipboardCopyIcon } from 'lucide-solid'

export function Basic() {
  return (
    <Clipboard.Root value="https://ui-ui.com">
      <Clipboard.Label>Copy this link</Clipboard.Label>
      <Clipboard.Control>
        <Clipboard.Input />
        <Clipboard.Trigger>
          <Clipboard.Indicator copied={<CheckIcon />}>
            <ClipboardCopyIcon />
          </Clipboard.Indicator>
        </Clipboard.Trigger>
      </Clipboard.Control>
    </Clipboard.Root>
  )
}
<script lang="ts">
  import { Clipboard } from '@destyler-ui/svelte'
</script>

{#snippet copied()}
  <span>Copied!</span>
{/snippet}

<Clipboard.Root value="https://destyler.org">
  <Clipboard.Label>Copy this link</Clipboard.Label>
  <Clipboard.Control>
    <Clipboard.Input />
    <Clipboard.Trigger>
      <Clipboard.Indicator {copied}><span>Copy</span></Clipboard.Indicator>
    </Clipboard.Trigger>
  </Clipboard.Control>
</Clipboard.Root>
<script setup lang="ts">
import { Clipboard } from '@destyler-ui/vue'
</script>
<template>
<Clipboard.Root>
<Clipboard.Label />
<Clipboard.Control>
<Clipboard.Input />
<Clipboard.Trigger>
<Clipboard.Indicator />
</Clipboard.Trigger>
</Clipboard.Control>
<Clipboard.ValueText />
</Clipboard.Root>
</template>
import { Clipboard } from '@destyler-ui/react'
export default function Basic() {
return (
<Clipboard.Root>
<Clipboard.Label />
<Clipboard.Control>
<Clipboard.Input />
<Clipboard.Trigger>
<Clipboard.Indicator />
</Clipboard.Trigger>
</Clipboard.Control>
<Clipboard.ValueText />
</Clipboard.Root>
)
}
import { Clipboard } from '@destyler-ui/solid'
export default function Basic() {
return (
<Clipboard.Root>
<Clipboard.Label />
<Clipboard.Control>
<Clipboard.Input />
<Clipboard.Trigger>
<Clipboard.Indicator />
</Clipboard.Trigger>
</Clipboard.Control>
<Clipboard.ValueText />
</Clipboard.Root>
)
}
<script lang="ts">
import { Clipboard } from '@destyler-ui/svelte'
</script>
{#snippet copied()}
<span>Copied!</span>
{/snippet}
<Clipboard.Root value="https://destyler.org">
<Clipboard.Label>Copy this link</Clipboard.Label>
<Clipboard.Control>
<Clipboard.Input />
<Clipboard.Trigger>
<Clipboard.Indicator {copied}><span>Copy</span></Clipboard.Indicator>
</Clipboard.Trigger>
</Clipboard.Control>
</Clipboard.Root>
<script setup lang="ts">
import { Clipboard } from '@destyler-ui/vue'
</script>

<template>
  <Clipboard.Root value="https.//destyler.org">
    <Clipboard.Label>Copy this link</Clipboard.Label>
    <Clipboard.Control>
      <Clipboard.Input />
      <Clipboard.Trigger>
        <Clipboard.Indicator>
          <span class="i-tabler-copy" />
          <template #copied>
            <span class="i-tabler-check" />
          </template>
        </Clipboard.Indicator>
      </Clipboard.Trigger>
    </Clipboard.Control>
  </Clipboard.Root>
</template>
import { Clipboard } from '@destyler-ui/react'

export function Basic() {
  return (
    <Clipboard.Root value="https://destyler.org">
      <Clipboard.Label>Copy this link</Clipboard.Label>
      <Clipboard.Control>
        <Clipboard.Input />
        <Clipboard.Trigger>
          <Clipboard.Indicator copied={
            <span>Copied!</span>
          }
          >
            <span>Copy</span>
          </Clipboard.Indicator>
        </Clipboard.Trigger>
      </Clipboard.Control>
    </Clipboard.Root>
  )
}
import { Clipboard } from '@destyler-ui/solid/clipboard'
import { CheckIcon, ClipboardCopyIcon } from 'lucide-solid'

export function Basic() {
  return (
    <Clipboard.Root value="https://ui-ui.com">
      <Clipboard.Label>Copy this link</Clipboard.Label>
      <Clipboard.Control>
        <Clipboard.Input />
        <Clipboard.Trigger>
          <Clipboard.Indicator copied={<CheckIcon />}>
            <ClipboardCopyIcon />
          </Clipboard.Indicator>
        </Clipboard.Trigger>
      </Clipboard.Control>
    </Clipboard.Root>
  )
}
<script lang="ts">
  import { Clipboard } from '@destyler-ui/svelte'
</script>

{#snippet copied()}
  <span>Copied!</span>
{/snippet}

<Clipboard.Root value="https://destyler.org">
  <Clipboard.Label>Copy this link</Clipboard.Label>
  <Clipboard.Control>
    <Clipboard.Input />
    <Clipboard.Trigger>
      <Clipboard.Indicator {copied}><span>Copy</span></Clipboard.Indicator>
    </Clipboard.Trigger>
  </Clipboard.Control>
</Clipboard.Root>

Use render function to customize the clipboard indicator.

<script setup lang="ts">
import { Clipboard } from '@destyler-ui/vue'
</script>

<template>
  <Clipboard.Root value="https.//destyler.org">
    <Clipboard.Label>Copy this link</Clipboard.Label>
    <Clipboard.Control>
      <Clipboard.Input />
      <Clipboard.Trigger>
        <Clipboard.Context v-slot="{ copied }">
          <span v-if="copied" class="i-tabler-check" />
          <span v-else class="i-tabler-copy" />
        </Clipboard.Context>
      </Clipboard.Trigger>
    </Clipboard.Control>
  </Clipboard.Root>
</template>
import { Clipboard } from '@destyler-ui/react'

export function RenderFn() {
  return (
    <Clipboard.Root value="https://destyler.org">
      <Clipboard.Label>Copy this link</Clipboard.Label>
      <Clipboard.Control>
        <Clipboard.Input />
        <Clipboard.Trigger>
          <Clipboard.Context>
            {clipboard => (clipboard.copied ? <span>Copied</span> : <span>Copy</span>)}
          </Clipboard.Context>
        </Clipboard.Trigger>
      </Clipboard.Control>
    </Clipboard.Root>
  )
}
import { Clipboard } from '@destyler-ui/solid/clipboard'
import { CheckIcon, ClipboardCopyIcon } from 'lucide-solid'
import { Show } from 'solid-js'

export function RenderFn() {
  return (
    <Clipboard.Root value="https://ui-ui.com">
      <Clipboard.Label>Copy this link</Clipboard.Label>
      <Clipboard.Control>
        <Clipboard.Input />
        <Clipboard.Trigger>
          <Clipboard.Context>
            {context => (
              <Show when={context().copied} fallback={<ClipboardCopyIcon />}>
                <CheckIcon />
              </Show>
            )}
          </Clipboard.Context>
        </Clipboard.Trigger>
      </Clipboard.Control>
    </Clipboard.Root>
  )
}
<script lang="ts">
  import { Clipboard } from '@destyler-ui/svelte'
</script>

<Clipboard.Root value="https://destyler.org">
  <Clipboard.Label>Copy this link</Clipboard.Label>
  <Clipboard.Control>
    <Clipboard.Input />
    <Clipboard.Trigger>
      <Clipboard.Context>
        {#snippet render(clipboard)}
          <span>{clipboard().copied ? 'Copied' : 'Copy'}</span>
        {/snippet}
      </Clipboard.Context>
    </Clipboard.Trigger>
  </Clipboard.Control>
</Clipboard.Root>
<script setup lang="ts">
import { Clipboard, useClipboard } from '@destyler-ui/vue'

const clipboard = useClipboard({ value: 'https.//destyler.org' })
</script>

<template>
  <button @click="clipboard.copy()">Copy</button>

  <Clipboard.RootProvider :value="clipboard">
    <Clipboard.Label>Copy this link</Clipboard.Label>
    <Clipboard.Control>
      <Clipboard.Input />
      <Clipboard.Trigger>
        <Clipboard.Indicator>
          <span class="i-tabler-copy" />
          <template #copied>
            <span class="i-tabler-check" />
          </template>
        </Clipboard.Indicator>
      </Clipboard.Trigger>
    </Clipboard.Control>
  </Clipboard.RootProvider>
</template>
import { Clipboard, useClipboard } from '@destyler-ui/react'

export function RootProvider() {
  const clipboard = useClipboard({ value: 'https://destyler.org' })

  return (
    <>
      <button onClick={() => clipboard.copy()}>Copy</button>

      <Clipboard.RootProvider value={clipboard}>
        <Clipboard.Label>Copy this link</Clipboard.Label>
        <Clipboard.Control>
          <Clipboard.Input />
          <Clipboard.Trigger>
            <Clipboard.Indicator copied={
              <span>Copied!</span>
            }
            >
              <span>Copy</span>
            </Clipboard.Indicator>
          </Clipboard.Trigger>
        </Clipboard.Control>
      </Clipboard.RootProvider>
    </>
  )
}
import { Clipboard, useClipboard } from '@destyler-ui/solid/clipboard'
import { CheckIcon, ClipboardCopyIcon } from 'lucide-solid'

export function RootProvider() {
  const clipboard = useClipboard({ value: 'https://ui-ui.com' })

  return (
    <>
      <button onClick={() => clipboard().copy()}>Copy</button>

      <Clipboard.RootProvider value={clipboard}>
        <Clipboard.Label>Copy this link</Clipboard.Label>
        <Clipboard.Control>
          <Clipboard.Input />
          <Clipboard.Trigger>
            <Clipboard.Indicator copied={<CheckIcon />}>
              <ClipboardCopyIcon />
            </Clipboard.Indicator>
          </Clipboard.Trigger>
        </Clipboard.Control>
      </Clipboard.RootProvider>
    </>
  )
}
<script lang="ts">
  import { Clipboard, useClipboard } from '@destyler-ui/svelte'

  const id = $props.id()
  const clipboard = useClipboard({ id, value: 'https://destyler.org' })
</script>

{#snippet copied()}
  <span>Copied!</span>
{/snippet}

<button type="button" onclick={() => clipboard().copy()}>Copy</button>
<Clipboard.RootProvider value={clipboard}>
  <Clipboard.Label>Copy this link</Clipboard.Label>
  <Clipboard.Control>
    <Clipboard.Input />
    <Clipboard.Trigger>
      <Clipboard.Indicator {copied}><span>Copy</span></Clipboard.Indicator>
    </Clipboard.Trigger>
  </Clipboard.Control>
</Clipboard.RootProvider>

Root

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

idstring

The unique identifier of the machine.

idsPartial<{ root: string; input: string; label: string; }>

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

timeout3000number

The timeout for the copy operation

valuestring

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

Context

No serializable props or emits are declared for this part.

Control

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Indicator

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Input

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Label

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*MachineApi<PropTypes>
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Trigger

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

ValueText

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

idsPartial<{ root: string; input: string; label: string; }>

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

onStatusChange(details: CopyStatusDetails) => void

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

timeout3000number

The timeout for the copy operation

valuestring

The value to be copied to the clipboard

Context

PropDefaultType
children*(context: UseClipboardContext) => ReactNode

Control

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Indicator

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

copiednull | string | number | bigint | false | true | react82.ReactElement<unknown, string | react82.JSXElementConstructor<any>> | Iterable<react82.ReactNode> | react82.ReactPortal | Promise<string | number | bigint | boolean | react82.ReactPortal | react82.ReactElement<unknown, string | react82.JSXElementConstructor<any>> | Iterable<react82.ReactNode> | null | undefined>

Input

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Label

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*UseClipboardReturn
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Trigger

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

ValueText

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChild(props: (userProps?: solid_js281.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

idsPartial<{ root: string; input: string; label: string; }>

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

onStatusChange(details: CopyStatusDetails) => void

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

timeout3000number

The timeout for the copy operation

valuestring

The value to be copied to the clipboard

Context

PropDefaultType
children*(context: UseClipboardContext) => Element

Control

PropDefaultType
asChild(props: (userProps?: solid_js281.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Indicator

PropDefaultType
asChild(props: (userProps?: solid_js281.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

copiednull | number | false | true | Node | solid_js281.JSX.ArrayElement | (string & {})

Input

PropDefaultType
asChild(props: (userProps?: solid_js281.JSX.InputHTMLAttributes<HTMLInputElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Label

PropDefaultType
asChild(props: (userProps?: solid_js281.JSX.LabelHTMLAttributes<HTMLLabelElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*UseClipboardReturn
asChild(props: (userProps?: solid_js281.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Trigger

PropDefaultType
asChild(props: (userProps?: solid_js281.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

ValueText

PropDefaultType
asChild(props: (userProps?: solid_js281.JSX.HTMLAttributes<HTMLSpanElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined
idstring
idsPartial<{ root: string; input: string; label: string; }>

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

onStatusChange(details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").ClipboardCopyStatusDetails) => void

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

timeout3000number

The timeout for the copy operation

valuestring

The value to be copied to the clipboard

Context

PropDefaultType
renderSnippet<[UseClipboardContext]>

Control

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined

Indicator

PropDefaultType
asChildSnippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined
copiedSnippet<[]> | undefined

Input

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"input">]>
childrenSnippet<[]> | undefined

Label

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"label">]>
childrenSnippet<[]> | undefined

Provider

No serializable props or emits are declared for this part.

RootProvider

PropDefaultType
value*UseClipboardReturn
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined

Trigger

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]>
childrenSnippet<[]> | undefined

ValueText

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"span">]>
childrenSnippet<[]> | undefined