Skip to content
Kappa
Clipboard Text
@dicehub/kappav0.4.2

Clipboard Text

Copies identifiers, tokens, and URLs to the clipboard with clear feedback.

Copy the ID, then paste it anywhere.
<script setup>
import { ClipboardText } from "@dicehub/kappa/components/clipboard-text";
</script>

<template>
  <ClipboardText.Root default-value="ws_01J9X4A8C2E6G0K4M8P2R6T0V4">
    <ClipboardText.Label>Workspace ID</ClipboardText.Label>
    <ClipboardText.Control>
      <ClipboardText.Input />
      <ClipboardText.Trigger aria-label="Copy workspace ID" />
    </ClipboardText.Control>
  </ClipboardText.Root>
</template>

Installation

Barrel

import {
  ClipboardText,
  ClipboardTextRoot,
  ClipboardTextRootProvider,
  ClipboardTextLabel,
  ClipboardTextControl,
  ClipboardTextInput,
  ClipboardTextTrigger,
  ClipboardTextIndicator,
  ClipboardTextValueText,
  ClipboardTextContext,
} from "@dicehub/kappa";

Granular

import {
  ClipboardText,
  ClipboardTextRoot,
  ClipboardTextRootProvider,
  ClipboardTextLabel,
  ClipboardTextControl,
  ClipboardTextInput,
  ClipboardTextTrigger,
  ClipboardTextIndicator,
  ClipboardTextValueText,
  ClipboardTextContext,
} from "@dicehub/kappa/components/clipboard-text";

Usage

A Control with a read-only Input and a copyTrigger covers the common case. The trigger swaps its icon to a check while the copied state is active.

<script setup>
import { ClipboardText } from "@dicehub/kappa/components/clipboard-text";
</script>

<template>
  <ClipboardText.Root default-value="https://example.com/docs/components/clipboard-text">
    <ClipboardText.Label>Documentation URL</ClipboardText.Label>
    <ClipboardText.Control>
      <ClipboardText.Input />
      <ClipboardText.Trigger aria-label="Copy documentation URL" />
    </ClipboardText.Control>
  </ClipboardText.Root>
</template>

Composition

Typical part hierarchy
ClipboardText.Root
├── ClipboardText.Label
├── ClipboardText.Control
│   ├── ClipboardText.Input
│   └── ClipboardText.Trigger
│       └── ClipboardText.Indicator
└── ClipboardText.ValueText (alternative)

Ark UI owns the copy machine, the clipboard write, the feedback timeout, and status announcements. Kappa owns the compound API, the default icon swap, the dense control geometry, and semantic tokens.

  • Root owns the value and the copied feedback state.
  • Trigger copies on click and renders both icons through Indicator.
  • Indicator renders its default slot, or its copied slot while feedback is active.
  • ValueText shows the value inline when the bordered control does not fit.

See the Ark UI Clipboardguide for the primitive behavior contract.

<script setup>
import {
  ClipboardTextRoot,
  ClipboardTextControl,
  ClipboardTextInput,
  ClipboardTextTrigger,
  ClipboardTextIndicator,
} from "@dicehub/kappa/components/clipboard-text";
</script>

<template>
  <ClipboardTextRoot default-value="custom-marks">
    <ClipboardTextControl>
      <ClipboardTextInput />
      <ClipboardTextTrigger aria-label="Copy value">
        <ClipboardTextIndicator>
          <CopyIcon />
          <template #copied><CheckIcon /></template>
        </ClipboardTextIndicator>
      </ClipboardTextTrigger>
    </ClipboardTextControl>
  </ClipboardTextRoot>
</template>

Examples

Inline Value

ValueText composes the value and trigger without the bordered control.

demo_access_token_not_valid
ValueText composes inline without the bordered control.
<script setup>
import { ClipboardText } from "@dicehub/kappa/components/clipboard-text";
</script>

<template>
  <ClipboardText.Root default-value="demo_access_token_not_valid">
    <ClipboardText.ValueText />
    <ClipboardText.Trigger aria-label="Copy access token" />
  </ClipboardText.Root>
</template>

Feedback Timeout

timeout controls how long the copied feedback stays visible.

<script setup>
import { ClipboardText } from "@dicehub/kappa/components/clipboard-text";
</script>

<template>
  <ClipboardText.Root default-value="token_short_feedback" :timeout="800">
    <ClipboardText.Label>Short feedback window (800 ms)</ClipboardText.Label>
    <ClipboardText.Control>
      <ClipboardText.Input />
      <ClipboardText.Trigger aria-label="Copy token" />
    </ClipboardText.Control>
  </ClipboardText.Root>
</template>

Controlled

Use v-model for the value and statusChange to react when a copy completes.

Last copied: none
<script setup>
import { ref } from "vue";
import { ClipboardText } from "@dicehub/kappa/components/clipboard-text";

const runId = ref("run_01J9X7KQ2M4V8N6P3R5T7W9Y0B");
const lastCopied = ref("none");
</script>

<template>
  <ClipboardText.Root
    v-model="runId"
    @status-change="lastCopied = $event.copied ? runId : lastCopied"
  >
    <ClipboardText.Label>Run ID</ClipboardText.Label>
    <ClipboardText.Control>
      <ClipboardText.Input />
      <ClipboardText.Trigger aria-label="Copy run ID" />
    </ClipboardText.Control>
  </ClipboardText.Root>
  <p>Last copied: {{ lastCopied }}</p>
</template>

Accessibility

  • The trigger is a button; give it a concise accessible name that names the copied value.
  • The input stays read-only and selectable, so keyboard users can copy manually.
  • The copied state announces through the primitive's status channel and swaps the icon visually.
  • Keyboard focus remains visible on the trigger and within the control.

API Reference

ClipboardText.Root

PropTypeDefaultDescription
modelValuestring-Controlled value to copy; supports v-model.
defaultValuestring-Value to copy for uncontrolled use.
timeoutnumber3000Milliseconds the copied feedback state stays active.
translationsIntlTranslationslocalizedAccessible names for the copy trigger and status announcements.
idstringgeneratedStable identifier for the clipboard state machine.
idsClipboardTextRootProps['ids']generatedOverrides generated root, input, and label IDs.
asChildbooleanfalseMerges root behavior into the single child element.

Parts

PartElementDescription
ClipboardText.LabellabelNames the field and focuses the value input on click.
ClipboardText.ControldivBordered box grouping the value input and copy trigger.
ClipboardText.InputinputRead-only monospaced value; selectable for manual copying.
ClipboardText.TriggerbuttonCopies on click; renders copy and check icons by default.
ClipboardText.IndicatordivSwitches between its default and copied slots on feedback.
ClipboardText.ValueTextspanInline value display for compositions without the control box.
ClipboardText.ContextrenderlessExposes the clipboard API to its slot.
ClipboardText.RootProviderdivRoot driven by an external useClipboard machine.

Events

EventPayloadDescription
statusChange{ copied: boolean }Emitted when the copied feedback state flips.
update:modelValuestringEmitted when the value changes; drives v-model.
valueChange{ value: string }Ark UI detail for value edits.

Exports

ExportDescription
ClipboardTextCompound API exposing every named part.
ClipboardTextRootUnaugmented root state machine host.
ClipboardTextTriggerCopy button with default icon swap.
ClipboardTextIndicatorDefault/copied slot switch.
ClipboardTextPropsPublic root props and Ark UI state contract.
ClipboardTextEmitsRoot event contract.
ClipboardCopyStatusDetailsPayload for statusChange.
useClipboardArk UI machine hook for external state control.
clipboardAnatomyArk UI part anatomy metadata.