examples/input-otp-pin.tsx
import { InputOtp } from "@/components/wensity/input-otp";export function InputOtpPin() {return (<InputOtplabel="Device PIN"mode="numeric"length={4}maskedhint="Use your PIN."/>);}
A React OTP input for two factor and verification codes, with SMS autofill, numeric or alphanumeric modes, masking, and success and error states.
Practical examples and common states for the same installable component.
Short numeric codes for device PINs and quick unlock flows.
Alphanumeric recovery codes with custom group separators.
Backup codes accept letters and numbers.
Show a confirmed code without the muted disabled treatment.
Hide entered characters for PIN-style entry.
Group digits with separators for easier scanning.
Input OTP is a React and Tailwind CSS one-time code input for verification and two factor sign in, in Next.js or any React app, built on the Base UI OTP field. It renders one box per character, six by default, and sets autocomplete to one-time-code so phones can offer the code from a text message. Numeric mode rejects letters with a Digits only hint, alphanumeric uppercases input, masked hides characters, and groups add a separator. An error status shakes the row, success draws a check, and loading pulses it. onComplete only fires when autoSubmit is on, so use onFilled otherwise.
Run the following command
pnpm dlx wensity@latest add input-otp
npx wensity@latest add input-otp
yarn dlx wensity@latest add input-otp
bunx wensity@latest add input-otp
Import InputOtp from @/components/wensity/input-otp and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.
import { InputOtp } from "@/components/wensity/input-otp";export function InputOtpDemo() {return (<InputOtplabel="Authentication code"mode="numeric"autoFocusautoSubmitonComplete={(value) => console.log(value)}/>);}
| Prop | Type | Default | Description |
|---|---|---|---|
length | number | 6 | Number of digit slots. |
mode | "numeric" | "alphanumeric" | "numeric" | Which characters are accepted, and the mobile keyboard shown. |
value | string | - | Controlled value. |
defaultValue | string | "" | Initial value when uncontrolled. |
onValueChange | (value: string) => void | - | Called on every change to the value. |
onComplete | (value: string) => void | - | Fires once every slot is filled by the user. Requires autoSubmit. |
onFilled | (value: string) => void | - | Fires when every slot is filled, without submitting. Never fires on mount. |
autoSubmit | boolean | false | Calls onComplete as soon as the last slot is filled. |
masked | boolean | false | Hides entered characters, for codes treated as secrets. |
groups | number[] | - | Slot grouping for separated layouts. Must sum to length — [3, 3] renders 123 . 456. |
separator | React.ReactNode | "•" | Node rendered between digit groups. |
status | "default" | "error" | "success" | - | Drives the success and error visuals and which message is shown. |
error | React.ReactNode | - | Message shown when status is error. |
success | React.ReactNode | - | Message shown when status is success. |
loading | boolean | false | Verifying state: locks input, sets aria-busy, and pulses the slots. |
loadingMessage | React.ReactNode | "Verifying…" | Screen-reader and helper copy while loading is true. |
readOnly | boolean | false | Locks input without the muted disabled styling. Useful after submit. |
inputSize | "sm" | "md" | "lg" | "md" | Slot size and text size. |
fullWidth | boolean | true | Stretches the slot row to fill its container. |
A React text input with a built in label, hint, and inline error wired to screen readers, plus leading and trailing icons and a one tap clear button.
A React field for form validation messages, linking a label, help text, and an error or success line to the input, in stacked or side by side layout.
A React form field wrapper that wires a label, description, and error to one control, with stack, inline, split, and card layouts plus form sections.
A React loading spinner in arc, ring, dots, and pulse styles with a screen reader label, five tones, three sizes, and an overlay that blocks a region.

A multi-step form wizard whose card physically reshapes to wrap each new step as the content slides in behind it.

A ceramic and graphite split-flap device that ripples each flap into your message.

A Mac keyboard with three finishes, a latching caps LED, and ANSI or ISO layouts.

A 65% QWERTY board with real key travel, live shift legends, and five colorways.