# hooks/useCopied (zidane-ui)

Import: `import { … } from 'zidane-ui'`. Source: [ui/src/hooks/useCopied.ts](https://github.com/Tahul/zidane/blob/main/ui/src/hooks/useCopied.ts).

## Functions

### `useCopied`

Function.

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

```ts
function useCopied(): CopiedState
```

**Returns** `CopiedState`

Source: [ui/src/hooks/useCopied.ts:23](https://github.com/Tahul/zidane/blob/main/ui/src/hooks/useCopied.ts#L23)

## Constants

### `COPIED_FEEDBACK_MS`

Constant.

How long a copy control shows that it copied.

```ts
const COPIED_FEEDBACK_MS = 1200
```

Source: [ui/src/hooks/useCopied.ts:8](https://github.com/Tahul/zidane/blob/main/ui/src/hooks/useCopied.ts#L8)

## Interfaces

### `CopiedState`

Interface.

What [`useCopied`](https://zidane.si/docs/reference/ui-hooks-use-copied.md#useCopied) returns.

```ts
interface CopiedState
```

**Properties**

- `copied` (`boolean`): 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`](https://zidane.si/docs/reference/ui-hooks-use-copied.md#COPIED_FEEDBACK_MS), after a copy the caller made itself (an image, a turn).

Source: [ui/src/hooks/useCopied.ts:11](https://github.com/Tahul/zidane/blob/main/ui/src/hooks/useCopied.ts#L11)
