Skip to content
TallCraftUI

Clipboard

Copy text to the clipboard with one click.

Basic usage

Blade
<x-clipboard content="Copied text" />

Customize clipboard

You can set the default icon using the icon attribute, change the icon displayed after copying with copied-icon, show a custom success message using copied-text, and adjust the duration of the copied state with the timeout option.
Blade
<x-clipboard
content="12345"
icon="document"
copied-icon="document-check"
copied-text="Text copied!"
timeout="5000"
/>

Events

You can trigger custom JavaScript logic using Alpine.js events. The x-on:copy event is fired when the content is successfully copied, allowing you to display a custom alert or any other interaction. The x-on:copy-error event is triggered if the copy action fails, enabling error handling.
Blade
<x-clipboard
content="12345"
x-on:copy="alert(`✅ Copied: ${$event.detail.text}`)"
x-on:copy-error="alert(`Error: ${$event.detail.error}`)"
/>

API reference

Props are read from the component classes in TallCraftUI 3.0.0-beta.1. Write them in kebab-case and pass booleans as bare attributes, for example <x-button outline />. Other attributes, such as class or wire:model, are passed to the component's element.

<x-clipboard>

View source
Prop Type Default
content string —
icon string 'clipboard'
copied-icon string 'clipboard-document-check'
copied-text string 'Copied!'
timeout int 2000