GodUI

OTP Input

A segmented one-time-code input with auto-advance, paste-to-fill, a traveling caret, and error shake.

Masked

Set mask to render entered characters as dots — useful for sensitive codes.

Validation status

status="error" shakes the row; status="success" settles it. Flip back to idle to re-arm the shake.

1
2
3
4
1
2
3
4
5
6

Installation

pnpm dlx shadcn@latest add "https://godui.design/r/otp-input.json"

Usage

tsx
 
import { OTPInput } from "@godui/components";

<OTPInput length={6} onComplete={(code) => verify(code)} />;

Props

PropTypeDefaultDescription
lengthnumber6Number of code cells.
valuestringControlled value.
defaultValuestring""Uncontrolled initial value.
type"numeric" | "alphanumeric""numeric"Accepted characters.
maskbooleanfalseRender characters as dots.
status"idle" | "error" | "success""idle"Validation state.
disabledbooleanfalseDisable input.
autoFocusbooleanfalseFocus on mount.
onChange(value: string) => voidFires on every change.
onComplete(value: string) => voidFires when the last cell fills.

On this page

Built with GodUI

Beautifully crafted motion components for modern interfaces.

Star on GitHub