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

Anatomie

Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.

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

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.

value
requis
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

Emplacements de contenu exposés par ce composant.

#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

Événements émis par ce composant.

@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

Membres exposés

Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.

() => 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.

Personnalisation

Variables CSS

Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.

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

Accessibilité

Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.

Interactions clavier

Interactions clavier
ToucheAction
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).

Fondation

Design tokens

Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.

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.

Interactif

Playground

Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.

Rendu de l’aperçu en cours…

Usage

Exemples

Extraits de code prêts à coller dans vos templates.

Default trigger

vue

Custom trigger via slot

vue

Inline inside OrigamCode

vue