Clipboard
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.
<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.
- valuerequiredstring—
- 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.
- feedbackDurationnumber2000
- Duration in ms that the copied flag stays true after a successful write before auto-resetting.
- feedbackTextstring'Copied!'
- Label shown inside the built-in trigger while copied is true. Pass a translated string for full i18n.
- successTextstring
- Alias for feedbackText. Takes precedence when both are provided.
- iconTIcon
- copiedIconTIcon
- disabledbooleanfalse
- Disables the copy action. The default trigger becomes non-interactive; the scoped slot still receives copy() but it short-circuits.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- tagstring'span'
- HTML root element tag.
- color
- Foreground color applied to the clipboard root.
- bgColor
- Background color applied to the clipboard root.
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>false
- Applies a border to the root element.
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
- Border-radius token applied to the root element.
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- marginboolean | number | string
- Margin applied to the root element.
- marginTopboolean | number | string
- marginLeftboolean | number | string
- marginBottomboolean | number | string
- marginRightboolean | number | string
- marginBlockboolean | number | string
- marginInlineboolean | number | string
- marginInlineStartboolean | number | string
- marginInlineEndboolean | number | string
- marginBlockStartboolean | number | string
- marginBlockEndboolean | number | string
- paddingboolean | number | string
- Padding applied to the root element.
- paddingTopboolean | number | string
- paddingLeftboolean | number | string
- paddingBottomboolean | number | string
- paddingRightboolean | number | string
- paddingBlockboolean | number | string
- paddingInlineboolean | number | string
- paddingInlineStartboolean | number | string
- paddingInlineEndboolean | number | string
- paddingBlockStartboolean | number | string
- paddingBlockEndboolean | number | string
- fontSizeTFontSize
- fontWeightTFontWeight
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.
- @copystring
- Fired after a successful clipboard write. Carries the payload string.
- @errorError
- 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
| Key | Action |
|---|---|
| Tab | Moves focus to the default trigger button. |
| Enter / Space | Triggers 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.
- colorvar(--origam-color__feedback--success---fgSubtle)
- Text color when copied.
- colorvar(--origam-color__feedback--success---bgSubtle)
- Background when copied.
- dimensionvar(--origam-font__size---xs)
- Trigger font size.
- durationvar(--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
Custom trigger via slot
Inline inside OrigamCode