pota/use/clipboardpota/use/clipboard ships ref factories you attach with use:ref:
clipboard(value) copies on click,
pasteText intercepts paste and strips
formatting, and pasteFiles captures
pasted images and files.
clipboard accepts these value shapes:
function — invoked with the click event; its return value is
copiedstring or number — that literal value is copiedtrue — the element's own innerText is copied, trimmedclipboard(value) — copy-on-click ref factory (documented below)pasteText(handler?) — strip formatting
on pastepasteFiles(handler) — capture pasted
filesEach button copies via a different value shape: true copies the
element's own text, a string copies a fixed literal, and a function is
called with the click event and its return value is copied.
import { render } from 'pota'
import { clipboard } from 'pota/use/clipboard'
function App() {
return (
<div>
<button use:ref={clipboard(true)}>
copy this label's text
</button>
<button use:ref={clipboard('hard-coded snippet')}>
copy a fixed string
</button>
<button use:ref={clipboard(() => `time: ${Date.now()}`)}>
copy current time
</button>
</div>
)
}
render(App)