# Input OTP

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/input-otp
- **Markdown:** https://refast.fastapicloud.dev/docs/components/input-otp.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/form_inputs/input_otp.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

Accessible one-time password input composed from individual slot primitives.
Supports configurable length, custom grouping, and separators.

```python
from refast.components.shadcn.controls import (
    InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator,
)

# Simple 6-digit OTP (auto-layout)
InputOTP(
    max_length=6,
    on_complete=ctx.callback(handle_complete),
)

# Custom layout: two groups of 3 separated by a dash
InputOTP(
    max_length=6,
    children=[
        InputOTPGroup(children=[
            InputOTPSlot(index=0),
            InputOTPSlot(index=1),
            InputOTPSlot(index=2),
        ]),
        InputOTPSeparator(),
        InputOTPGroup(children=[
            InputOTPSlot(index=3),
            InputOTPSlot(index=4),
            InputOTPSlot(index=5),
        ]),
    ],
    on_complete=ctx.callback(handle_complete),
)
```

```python
InputOTP(
    max_length=6,
    disabled=False,
    required=False,
    on_change=ctx.callback(handle_change),
    on_complete=ctx.callback(handle_complete),
)
```

## InputOTP Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `max_length` | `int` | `6` | Total number of OTP characters |
| `value` | `str \| None` | `None` | Controlled value |
| `disabled` | `bool` | `False` | Disables all slots |
| `pattern` | `str \| None` | `None` | Regex pattern to validate each character |
| `label` | `str \| None` | `None` | Label text |
| `description` | `str \| None` | `None` | Help text below label |
| `required` | `bool` | `False` | Shows required asterisk |
| `error` | `str \| None` | `None` | Error message |
| `on_change` | `Callback \| None` | `None` | Fired with the current OTP string on every keystroke |
| `on_complete` | `Callback \| None` | `None` | Fired when all slots are filled |
| `children` | `list \| None` | `None` | Custom `InputOTPGroup` / `InputOTPSeparator` layout |

## InputOTPSlot Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `index` | `int` | required | Zero-based position within the parent `InputOTP` |

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
