third party plugins
Tailwind CSS Clipboard
Clipboard components are vital tools that simplify data copying and pasting in applications, boosting user efficiency and enhancing overall interaction.
Below are the comprehensively outlined steps you can follow to seamlessly integrate Clipboard JS into your project for efficient text copying functionality.
To copy text from a specific element, target it using its Id
and assign it to the data-clipboard-target
attribute in the trigger button. Additionally, set the value of the data-clipboard-action
attribute to copy
. This setup ensures that clicking the button will copy the text from the targeted element to the clipboard.
The following example demonstrates the default usage of the copy clipboard component.
npm install flyonui
Use the copy-clipboard-success-text
component class to display default text, and set the value of the data attribute data-clipboard-success-text
to specify the text that should appear after the content is successfully copied to the clipboard.
Below example showcases how to utilize the copy clipboard component with an input field.
Below example showcases how to utilize the copy clipboard component with an input group.
Below examples showcases how to utilize the copy clipboard functionality with tooltips.
The example below illustrates the use of the copy clipboard component along with a tooltip displaying a static success message only.
$
npm i flyonui
The example below illustrates the use of the copy clipboard component along with a tooltip displaying a dynamic success message.
$
npm i flyonui
Below is an example demonstrating the extended functionality of the copy clipboard component. It includes a centered tooltip that dynamically displays a success message. This setup enables copying by clicking anywhere within the element.
The example below illustrates the use of the copy clipboard component in modals.
The example below illustrates the use of the copy clipboard component in source code block.
const clipboard = new ClipboardJS(el, {
text: trigger => {
const clipboardText = trigger.dataset.clipboardText
if (clipboardText) return clipboardText
const clipboardTarget = trigger.dataset.clipboardTarget
const $element = document.querySelector(clipboardTarget)
if ($element.tagName === 'SELECT' || $element.tagName === 'INPUT' || $element.tagName === 'TEXTAREA')
return $element.value
else return $element.textContent
}
})