vwf .

API Reference

Complete API documentation for components, utilities, and framework core

Reference/API/OTPInput

OTPInput

One-time password input with auto-focus progression and paste support

🔧 Props

PropertyTypeDefaultDescription
lengthnumber6Number of OTP digits (4-8)
value*van.state-Parent state (auto-updated as user types)
autofocusbooleanfalseAuto-focus first input on mount
onCompletefunctionundefinedCallback when all digits entered
disabledbooleanfalseDisable all inputs
classstring-Input classes (overrides defaults)
containerClassstring-Container wrapper classes

✨ Features

Smart navigation: auto-advance on digit, backspace to previous

Full paste support with numeric filtering

Keyboard navigation (arrow keys)

Numeric-only input with mobile numeric keyboard

Dual-state pattern: individual inputs + parent state

💻 Examples

OTP Verification

const otp = van.state('');
return OTPInput({
  value: otp,
  autofocus: true,
  onComplete: (code) => {
    console.log('OTP:', code);
    verifyOTP(code);
  }
});

▶️ Live Preview

💡 Click "Edit Code" to modify the example

🔄 Click "Apply Changes" to see your modifications

↩️ Click "Reset" to restore original code

💡 Usage Tips

🔗 Related

Explore vwf

Discover what vwf can do