- Plugins
- Copy Markup
Plugins
Tailwind CSS Copy Markup
Copy input, select or other markups.
Installation
To get started, install Copy Markup plugin via npm, else you can skip this step if you are already using Preline UI as a package.
npm i @preline/copy-markup
Basic usage
Prefer to create your own style? Here is a completely unstylized example.
<div id="hs-wrapper-for-copy">
<input id="hs-content-for-copy" type="text" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm text-gray-800 focus:z-10 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-200 dark:placeholder:text-neutral-500" placeholder="Enter Name">
</div>
<button type="button" data-hs-copy-markup='{
"targetSelector": "#hs-content-for-copy",
"wrapperSelector": "#hs-wrapper-for-copy",
"limit": 3
}' id="hs-copy-content">
Add Name
</button>
Methods
The HSCopyMarkup
object is contained within the global window
object
Open item (public method).
const copyMarkup = new HSCopyMarkup(document.querySelector('#copy-markup'));
const deleteBtn = document.querySelector('#delete-btn');
deleteBtn.addEventListener('click', () => {
copyMarkup.delete(document.querySelector('#copy-markup-item-1'));
});
Open item (mixed).
const { element } = HSCopyMarkup.getInstance('#copy-markup', true);
const deleteBtn = document.querySelector('#delete-btn');
deleteBtn.addEventListener('click', () => {
element.delete(document.querySelector('#copy-markup-item-1'));
});
Events
Call any function on copy
example.
const el = HSCopyMarkup.getInstance('#copy-markup');
el.on('copy', (copiedElement) => {...});
Demo examples
Looking for prebuilt UI components based on the Tailwind CSS? Preline UI packs hundreds of component examples for all your website needs.
Check out Preline UI Components