<div class="flex items-center gap-4">
<input type="text" class="input" value="Hello Skeleton" data-source />
<button class="btn preset-filled" data-trigger>Copy</button>
// Create element references
const elemButton: HTMLButtonElement | null = document.querySelector('[data-trigger]');
const elemInput: HTMLInputElement | null = document.querySelector('[data-source]');
// Add a click event handler to the trigger
elemButton?.addEventListener('click', () => {
// Call `navigator.clipboard`
// Use the `writeText` method write to the clipboard
.writeText(elemInput?.value || '')
// Handle the completed state
.then(() => console.log('Input value copied to clipboard!'));