Your browser does not support Clipboard API

useClipboard

Reactive Clipboard API. Provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard. Access to the contents of the clipboard is gated behind the Permissions API without user permission, reading or altering the clipboard contents is not permitted.

Usage

import { useClipboard } from '@vueuse/core'

const { text, copy, isSupported } = useClipboard()
StateTypeDescription
isSupportedbooleanthe current environment support Clipboard API or not.
textstringthe current text in the clipboard.
MethodDescription
copy(str: string)Writes the given string it in the clipboard.

Type Declarations

/**
 * Reactive Clipboard API.
 *
 * @see   {@link /useClipboard}
 * @param options
 */
export declare function useClipboard({
  navigator,
}?: ConfigurableNavigator): {
  isSupported: boolean | undefined
  text: Ref<string>
  copy: (txt: string) => Promise<void>
}

Source

SourceDemoDocs