# VerificationCode

Shows a code that a person compares with the one another app shows.

[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/VerificationCode.tsx)

Figma: [Content/Verification Code](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-3952) (`VerificationCode.Root`)

## Overview

A verification code renders a centered box with a label above a large code. A person reads the code and checks that it matches the code on another device or app, such as in a device sign-in.

## Examples

### Basic

```tsx
import { VerificationCode } from '@tempoxyz/ds'

export function Demo() {
  return (
    <VerificationCode.Root>
      <VerificationCode.Label>Confirm this code matches Claude</VerificationCode.Label>
      <VerificationCode.Value>WXYZ-4821</VerificationCode.Value>
    </VerificationCode.Root>
  )
}
```

[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/VerificationCode/Basic.tsx)

## Anatomy

Import the component and assemble its parts.

```tsx
import { VerificationCode } from '@tempoxyz/ds'

<VerificationCode.Root>
  <VerificationCode.Label />
  <VerificationCode.Value />
</VerificationCode.Root>
```

## Guidelines

### When to Use

* Confirm a device sign-in by matching the code that an app or a terminal shows.
* Pair two devices by a code that both show.

### When Not to Use

* Use [OtpField](/docs/components/otp-field) when the person types a code.
* Use [Snippet](/docs/components/snippet) for a command or a value to copy.

### Match the Other Device

**Do:** Name the app that shows the code, and keep its grouping.

```tsx
import { VerificationCode } from '@tempoxyz/ds'

export function Demo() {
  return (
    <VerificationCode.Root>
      <VerificationCode.Label>Confirm this code matches Claude</VerificationCode.Label>
      <VerificationCode.Value>WXYZ-4821</VerificationCode.Value>
    </VerificationCode.Root>
  )
}
```

**Don't:** Regroup the code, or leave out where it comes from.

```tsx
import { VerificationCode } from '@tempoxyz/ds'

export function Demo() {
  return (
    <VerificationCode.Root>
      <VerificationCode.Label>Your code</VerificationCode.Label>
      <VerificationCode.Value>WX YZ 48 21</VerificationCode.Value>
    </VerificationCode.Root>
  )
}
```

## Content

### Write the Label

Start the label with the action, such as Confirm this code matches Claude. Name the app or device that shows the other code.

## Accessibility

A verification code renders a `<div>` with the label in a `<p>` and the code in a `<span>`. Screen readers read the label, then the code.

### Semantics

* **Label (p):** Screen readers read the label before the code.
* **Value (translate=no):** Browsers do not translate the code, and a click selects all of it.

### Your Responsibilities

* **Keep the Code on Screen (SC 3.3.8):** Show the code until the sign-in finishes, so people can compare it.

## Related

[OtpField](/docs/components/otp-field)

Use for a code that a person types.

[Snippet](/docs/components/snippet)

Use for a command or a value to copy.
