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
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<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.
- valuerequisstring—
- 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
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.
- @copystring
- Fired after a successful clipboard write. Carries the payload string.
- @errorError
- 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
| Touche | 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).
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.
- 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.
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
Custom trigger via slot
Inline inside OrigamCode