# OTP Input

> A one-time code as separate boxes that type, delete, paste and autofill like one field.

- Tier: free, MIT
- Category: Forms
- Docs: https://ui.mlola.com/docs/components/otp-input

## Install

```bash
npx mlola-ui add otp-input
```

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

## Props with fixed values

| Component | Prop | Values | Default | Description |
| --- | --- | --- | --- | --- |
| OtpInput | `mode` | `numeric`, `alphanumeric` | `numeric` | "numeric" (default) or "alphanumeric". |

## Example

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

export default function Example() {
  return <OtpInput label="Verification code" hint="Sent to your email." length={6} />;
}
```

## The same markup without React

```html
<div class="ml-input-field">
  <label class="ml-input-label" id="otp-1-label" for="otp-1">Verification code</label>
  <div class="ml-otp" role="group" aria-labelledby="otp-1-label">
    <input class="ml-otp-box" id="otp-1" inputMode="numeric" autoComplete="one-time-code" aria-label="Digit 1 of 6" aria-describedby="otp-1-hint" maxLength="6" value=""/>
    <input class="ml-otp-box" inputMode="numeric" autoComplete="off" aria-label="Digit 2 of 6" maxLength="1" value=""/>
    <input class="ml-otp-box" inputMode="numeric" autoComplete="off" aria-label="Digit 3 of 6" maxLength="1" value=""/>
    <input class="ml-otp-box" inputMode="numeric" autoComplete="off" aria-label="Digit 4 of 6" maxLength="1" value=""/>
    <input class="ml-otp-box" inputMode="numeric" autoComplete="off" aria-label="Digit 5 of 6" maxLength="1" value=""/>
    <input class="ml-otp-box" inputMode="numeric" autoComplete="off" aria-label="Digit 6 of 6" maxLength="1" value=""/>
  </div>
  <p class="ml-input-hint" id="otp-1-hint">Sent to your email.</p>
</div>
```
