Skip to content

OtpInput

One-time-code entry as single-character boxes with a synced hidden input for native form submit. Typing auto-advances, Backspace steps back, pasting a code fills every box.

Example

Enter the 6-digit code we sent you.

<OtpInput
  id="code"
  label="Verification code"
  name="code"
  length={6}
  hint="Enter the 6-digit code we sent you."
/>

Error state

That code has expired.

<OtpInput
  id="pin"
  label="PIN"
  name="pin"
  length={4}
  error="That code has expired."
/>

Props

PropTypeDefaultDescription
idstring-Required. Base for box ids (#{id}-0…) and message ids.
labelstringVerification codeVisible label; targets the first box.
namestringidHidden input form name; submits the joined digits.
lengthnumber6Number of digit boxes.
hintstring-Help text below the boxes.
errorstring-Error message; sets aria-invalid on every box.
requiredbooleanfalseMarks and enforces required on each box.
disabledbooleanfalseNon-interactive.
classstring-Style passthrough.

Accessibility