# OTP input preview

Interactive preview of the CyberSpec OTP input component. One cut cell per character of a code, with a blinking caret in the active one.

[View OTP input preview on CyberSpec](https://www.cyberspec.dev/preview/otp-input)

## About this preview

OTP input belongs to the Fields group in the CyberSpec catalog. It uses @ui-sdk/react/otp-input, @ui-sdk/react/field.

## Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/otp-input.json
```

## Example

```tsx
"use client"

import { OtpInput } from "@/components/ui/otp-input"

export default function OtpInputDemo() {
  return (
    <>
      <OtpInput label="Access code" pattern="alphanumeric" defaultValue="7K4" hint="Six characters, sent to your deck by the Vanta relay." />
      <OtpInput label="Vault pin" length={4} defaultValue="0417" error="Pin expired. Request a new one." />
    </>
  )
}
```

## Install this example

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/otp-input-demo.json
```

## Resources

- [OTP input documentation](https://www.cyberspec.dev/components/sidebar/otp-input.md)
- [Component catalog](https://www.cyberspec.dev/components.md)
- [OTP input source code](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/ui/otp-input.tsx)
- [Shadcn registry item](https://www.cyberspec.dev/r/otp-input.json)
