fn
useClipboard
v0.0.15testeddemoReactive async Clipboard API.
Examples
ts
const { text, copy, copied, isSupported } = useClipboard();
copy('hello');ts
// Copy a lazily/asynchronously resolved value
copy(async () => (await fetch('/token').then(r => r.text())));Demo
Loading demo…
Signatures
ts
export function useClipboard(options?: UseClipboardOptions<undefined>): UseClipboardReturn<false>;ts
export function useClipboard(options: UseClipboardOptions<MaybeRefOrGetter<string>>): UseClipboardReturn<true>;Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UseClipboardOptions<MaybeRefOrGetter<string> | undefined> | Options |
Returns
UseClipboardReturn<boolean>`isSupported`, `text`, `copied`, `copyPending`, and `copy`