pota/use/clipboard

pota/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:

Exports

Examples

Value shapes

Each 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)