Skip to main content
  1. Docs
  2. Components
  3. Forms

OTP input

A one-time code in slots. Paste fills them all; the phone's SMS autofill lands in one go.

Import
@qeetrix/react/experimental
Status
ExperimentalSince 0.0.4
Renders
<input> per slotServer-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

When to use

Use it for
  • A code sent by SMS or email, or from an authenticator app.
  • A recovery code, in groups.
Not for

02

Anatomy

  1. 1field-label<label>Names the slots' group, and the first slot.
  2. 2otp-input<div role="group">The slots, sharing the width; they shrink to fit.
  3. 3otp-input-slot<input>One character; the others say where they are: "Character 2 of 6".

03

Do and don't

Say where it went
DoThe description says where the code was sent.
Don'tA code from somewhere.

04

Content

  • Say where the code was sent, and for how long it lasts.
  • Offer a new code in words: "Send a new code".
  • Errors say what to do: "That code has expired. Send a new one."
Next — OTP inputAPI