Skip to content

hooks/useCopied

import { … } from 'zidane-ui'ui/src/hooks/useCopied.ts

Functions#

useCopiedFunction#

The copied state of one copy control. Stable callbacks; a copy while it shows starts the moment again.

TypeScript
function useCopied(): CopiedState

ui/src/hooks/useCopied.ts:23

Constants#

COPIED_FEEDBACK_MSConstant#

How long a copy control shows that it copied.

TypeScript
const COPIED_FEEDBACK_MS = 1200

ui/src/hooks/useCopied.ts:8

Interfaces#

CopiedStateInterface#

What useCopied returns.

TypeScript
interface CopiedState
CopiedState properties
NameTypeDescription
copiedboolean

A copy just happened: show the copied state.

copy(text: string) => Promise<boolean>

Writes text to the clipboard, then shows the copied state. Resolves whether it copied.

markCopied() => void

Shows the copied state for COPIED_FEEDBACK_MS, after a copy the caller made itself (an image, a turn).

ui/src/hooks/useCopied.ts:11