# Shadcn UI Input Otp

> Build OTP input with ShadInputOTP, ShadInputOTPGroup, ShadInputOTPSlot; maxLength, inputFormatters, ShadInputOTPFormField. Use when adding one-time password or verification code inputs in a Flutter shadcn_ui app.

- Skill: `serverpod/shadcn-ui-input-otp` (Agent Skill)
- Install (CLI): `npx skillmds@latest add serverpod/shadcn-ui-input-otp`
- Raw SKILL.md: https://api.skillmd.com/api/skills/serverpod/shadcn-ui-input-otp/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: serverpod (https://skillmd.com/u/serverpod)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/serverpod/shadcn-ui-input-otp

---


# Shadcn UI — Input OTP

## Instructions

`ShadInputOTP` is an accessible one-time password component with copy-paste support. Use `children` to build the layout: `ShadInputOTPGroup` containing `ShadInputOTPSlot`s, with optional separators (e.g. `Icon(LucideIcons.dot)`). Set `maxLength`; use `onChanged` for the full OTP string. Restrict input with `keyboardType` and `inputFormatters` (e.g. `FilteringTextInputFormatter.digitsOnly`). For forms use `ShadInputOTPFormField` with `id`, `label`, `validator`.

### Basic

```dart
ShadInputOTP(
  onChanged: (v) => print('OTP: $v'),
  maxLength: 6,
  children: const [
    ShadInputOTPGroup(
      children: [
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
      ],
    ),
    Icon(size: 24, LucideIcons.dot),
    ShadInputOTPGroup(
      children: [
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
      ],
    ),
  ],
)
```

### With input formatters (digits only)

```dart
ShadInputOTP(
  onChanged: (v) => print('OTP: $v'),
  maxLength: 4,
  keyboardType: TextInputType.number,
  inputFormatters: [
    FilteringTextInputFormatter.digitsOnly,
  ],
  children: const [
    ShadInputOTPGroup(
      children: [
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
      ],
    ),
  ],
)
```

The package also provides `UpperCaseTextInputFormatter` and `LowerCaseTextInputFormatter`.

### Form field

```dart
ShadInputOTPFormField(
  id: 'otp',
  maxLength: 6,
  label: const Text('OTP'),
  description: const Text('Enter your OTP.'),
  validator: (v) {
    if (v.contains(' ')) return 'Fill the whole OTP code';
    return null;
  },
  children: const [
    ShadInputOTPGroup(
      children: [
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
      ],
    ),
    Icon(size: 24, LucideIcons.dot),
    ShadInputOTPGroup(
      children: [
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
        ShadInputOTPSlot(),
      ],
    ),
  ],
)
```

