<div
id="container-example"
class="fixed right-0 top-0 z-[2000] me-3 mt-[59px] hidden w-1/4 items-center rounded-lg bg-primary-100 px-6 py-4 text-base text-primary-700 data-[twe-alert-show]:inline-flex dark:bg-slate-900 dark:text-primary-500"
role="alert"
data-twe-alert-init
data-twe-autohide="true"
data-twe-delay="4000">
Text copied!
</div>
<div class="flex w-full">
<div class="relative mb-3 w-full" data-twe-input-wrapper-init>
<input
type="text"
class="peer block min-h-[auto] w-full rounded border-0 bg-transparent px-3 py-[0.32rem] leading-[1.6] outline-none transition-all duration-200 ease-linear focus:placeholder:opacity-100 peer-focus:text-primary data-[twe-input-state-active]:placeholder:opacity-100 motion-reduce:transition-none dark:text-white dark:placeholder:text-neutral-300 dark:autofill:shadow-autofill dark:peer-focus:text-primary [&:not([data-twe-input-placeholder-active])]:placeholder:opacity-0"
id="copy-target-4"
placeholder="Example label" />
<label
for="copy-target"
class="pointer-events-none absolute left-3 top-0 mb-0 max-w-[90%] origin-[0_0] truncate pt-[0.37rem] leading-[1.6] text-neutral-500 transition-all duration-200 ease-out peer-focus:-translate-y-[0.9rem] peer-focus:scale-[0.8] peer-focus:text-primary peer-data-[twe-input-state-active]:-translate-y-[0.9rem] peer-data-[twe-input-state-active]:scale-[0.8] motion-reduce:transition-none dark:text-neutral-400 dark:peer-focus:text-primary"
>Type here text to copy
</label>
</div>
<div>
<button
id="myExample"
type="button"
data-twe-clipboard-init
data-twe-clipboard-target="#copy-target-4"
data-twe-ripple-init
data-twe-ripple-color="light"
class="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-primary-3 transition duration-150 ease-in-out hover:bg-primary-accent-300 hover:shadow-primary-2 focus:bg-primary-accent-300 focus:shadow-primary-2 focus:outline-none focus:ring-0 active:bg-primary-600 active:shadow-primary-2 dark:shadow-black/30 dark:hover:shadow-dark-strong dark:focus:shadow-dark-strong dark:active:shadow-dark-strong">
Copy
</button>
</div>
</div>
// Initialization for ES Users
import {
Alert,
Clipboard,
Input,
Ripple,
initTWE,
} from "tw-elements";
initTWE({ Alert, Clipboard, Input, Ripple });
const myExample = document.getElementById("myExample");
const alertInstance = Alert.getInstance(
document.getElementById("container-example")
);
myExample.addEventListener("copied.twe.clipboard", () => {
myExample.innerText = "Copied!";
alertInstance.show();
setTimeout(() => {
myExample.innerText = "COPY";
}, 4000);
});
const myExample = document.getElementById("myExample");
const alertInstance = twe.Alert.getInstance(
document.getElementById("container-example")
);
myExample.addEventListener("copied.twe.clipboard", () => {
myExample.innerText = "Copied!";
alertInstance.show();
setTimeout(() => {
myExample.innerText = "COPY";
}, 4000);
});