Clipboard

Utilities & Providers
stable

Chrome-less copy-to-clipboard wrapper. Owns the navigator.clipboard.writeText pipeline and an auto-resetting "copied" flag. The default trigger is a single icon button; replace it entirely via the default scoped slot.

Structure

Anatomy

Visual breakdown of the component's internal structure with BEM class call-outs.

Anatomy of OrigamClipboardSchematic of the Clipboard component with 4 numbered internal parts. default-trigger default-label (visible when copied = true) 1 2 3 ② and ③ are the built-in trigger — replaced when #default slot is provided
Anatomy of <origam-clipboard> — root wrapper + optional default trigger (button + feedback label).
1.origam-clipboard
Root element (default tag: span). Carries BEM modifiers --copied and --disabled.
2.origam-clipboard__default-trigger
Built-in trigger button (all: unset). Rendered only when no #default slot is provided.
3.origam-clipboard__default-label
Feedback text label (aria-live="polite"). Visible only when copied=true.
4.origam-clipboard__default-icon
OrigamIcon inside the default trigger. Switches between mdi-content-copy and mdi-check on copy.

API

Props

All props accepted by this component, with their type, default value and description.

value
required
string
—
Text payload written to the clipboard on copy(). Re-read on each trigger so a parent that mutates the value between calls always copies the latest string.
feedbackDuration
number
2000
Duration in ms that the copied flag stays true after a successful write before auto-resetting.
feedbackText
string
'Copied!'
Label shown inside the built-in trigger while copied is true. Pass a translated string for full i18n.
successText
string
Alias for feedbackText. Takes precedence when both are provided.
icon
TIcon
copiedIcon
TIcon
disabled
boolean
false
Disables the copy action. The default trigger becomes non-interactive; the scoped slot still receives copy() but it short-circuits.
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
tag
string
'span'
HTML root element tag.
color
Foreground color applied to the clipboard root.
bgColor
Background color applied to the clipboard root.
border
boolean | number | string | TDirectionBoth | Array<TDirectionBoth>
false
Applies a border to the root element.
borderTop
boolean | number | string
borderLeft
boolean | number | string
borderBottom
boolean | number | string
borderRight
boolean | number | string
borderBlock
boolean | number | string
borderInline
boolean | number | string
borderInlineStart
boolean | number | string
borderInlineEnd
boolean | number | string
borderBlockStart
boolean | number | string
borderBlockEnd
boolean | number | string
borderColor
string
borderStyle
string
borderTopColor
TColor
borderRightColor
TColor
borderBottomColor
TColor
borderLeftColor
TColor
borderInlineStartColor
TColor
borderInlineEndColor
TColor
borderBlockStartColor
TColor
borderBlockEndColor
TColor
Border-radius token applied to the root element.
roundedTopRight
boolean | number | string
roundedTopLeft
boolean | number | string
roundedBottomLeft
boolean | number | string
roundedBottomRight
boolean | number | string
roundedStartStart
boolean | number | string
roundedStartEnd
boolean | number | string
roundedEndStart
boolean | number | string
roundedEndEnd
boolean | number | string
margin
boolean | number | string
Margin applied to the root element.
marginTop
boolean | number | string
marginLeft
boolean | number | string
marginBottom
boolean | number | string
marginRight
boolean | number | string
marginBlock
boolean | number | string
marginInline
boolean | number | string
marginInlineStart
boolean | number | string
marginInlineEnd
boolean | number | string
marginBlockStart
boolean | number | string
marginBlockEnd
boolean | number | string
padding
boolean | number | string
Padding applied to the root element.
paddingTop
boolean | number | string
paddingLeft
boolean | number | string
paddingBottom
boolean | number | string
paddingRight
boolean | number | string
paddingBlock
boolean | number | string
paddingInline
boolean | number | string
paddingInlineStart
boolean | number | string
paddingInlineEnd
boolean | number | string
paddingBlockStart
boolean | number | string
paddingBlockEnd
boolean | number | string
fontSize
TFontSize
fontWeight
TFontWeight

API

Slots

Content slots exposed by this component.

#default
Custom trigger. Receives copy() (async), copied (boolean) and error (Error | null). When omitted the component renders a default icon button with mdi-content-copy.
#feedback
Custom feedback marker rendered when copied is true. Receives the copied boolean for symmetry with the default slot.

API

Emits

Events emitted by this component.

@copy
string
Fired after a successful clipboard write. Carries the payload string.
@error
Error
Fired after a failed write (clipboard API denied, no permission, etc.).

API

Exposed members

Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.

() => Promise<boolean>
Triggers the copy pipeline programmatically. Returns true on success.
Ref<boolean>
Reactive boolean — true for feedbackDuration ms after a successful copy.
Ref<Error | null>
Set when the last copy attempt threw an error. Null otherwise.

Customisation

CSS variables

CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.

Text color of the default trigger while copied=true.
Background color of the default trigger while copied=true.
Font size of the default trigger.
Border radius of the default trigger button.
Gap between the icon and the feedback label inside the default trigger.
Duration of color and background-color transitions.

Inclusion

Accessibility

ARIA roles, keyboard navigation and focus management. Sourced from the real component template.

Keyboard interactions

Keyboard interactions
KeyAction
TabMoves focus to the default trigger button.
Enter / SpaceTriggers the copy action from the focused default trigger button.

Notes

  • The default trigger carries a dynamic aria-label that changes from "Copy to clipboard" to "Value copied to clipboard" once copied. Sourced from useLocale for full i18n.
  • The feedback label has aria-live="polite" so screen readers announce the success state without interrupting the current reading.
  • When disabled=true the default trigger has the disabled HTML attribute; the copy() exposed method short-circuits immediately.
  • When using a custom #default slot, ensure your trigger element has an appropriate aria-label and keyboard handler (or use origam-btn which handles both).

Foundation

Design tokens

Excerpt from this component's token declarations — the --origam-<component>---<property> variables, declared in its hand-maintained token sheet with no build step.

Source
color
var(--origam-color__feedback--success---fgSubtle)
Text color when copied.
color
var(--origam-color__feedback--success---bgSubtle)
Background when copied.
dimension
var(--origam-font__size---xs)
Trigger font size.
duration
var(--origam-motion__duration---medium)
Color/background transition duration.

Interactive

Playground

Edit props live and see the component update in real time. The generated code snippet updates as you change values.

Rendering the live preview…

Usage

Examples

Ready-to-paste code snippets for your templates.

Default trigger

vue

Custom trigger via slot

vue

Inline inside OrigamCode

vue