Castle logo

CASTLE UI

Search

K

useClipboard is a custom hook that handles copying content to clipboard.

Arguments

The useClipboard hook takes the following arguments:

NameTypeRequiredDescription
textstringtrueThe text or value that is to be copied.
optionsOrTimeoutnumber or objectfalseThe timeout as a number or an object containing 2 properties: timeout and format for the MIME type

Return value

The useClipboard hook returns an object with the following fields:

NameTypeDefaultDescription
valuestringThe copied value.
onCopyfunctionCallback function to copy content.
hasCopiedbooleanfalseIf true, the content has been copied.
errorstringnullIf set, contains an error message if the copy operation failed.
clipboardPermissionstringnullThe current clipboard permission state (granted, denied, or prompt).

Import

import { useClipboard } from '@passfort/castle'

Copy

Usage

Copy

live example

Contents