shadcn_ui-input-otp

Installation
SKILL.md

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 ShadInputOTPSlots, 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

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)

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

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(),
      ],
    ),
  ],
)
Related skills

More from serverpod/skills-registry

Installs
6
GitHub Stars
8
First Seen
Apr 13, 2026