shadcn.io is not affiliated with official shadcn/ui
Input OTP examples · States
OTP with Success State Input OTP for React
A one-time code field that locks and shows a check once a complete code is verified.
Confirmation closes the loop. This example verifies the code half a second after the sixth digit is typed, then disables the field and shows a check with Code verified successfully! in the theme's success color.
Preview
Installation
FAQ
When is the code verified?
When every slot is filled; a half-second timer stands in for the request.
onComplete fires when the code reaches maxLength.
Why is the field disabled afterwards?
So the accepted code can't be changed. disabled comes from the same success state that shows the message.
How is the confirmation shown?
A row in text-success with a CheckIcon and Code verified successfully!, with role status so it's announced.
What if the code changes before it's verified?
Every change resets the success state, so only a complete code shows the confirmation.
Related
- OTP with Loading State Input OTPA one-time code field that shows a
- OTP with Error State Input OTPA one-time code field that turns invalid
- Disabled OTP Input Input OTPA disabled one-time code field with a
- Success with Title AlertA success alert with only a title, for a
- Two-Factor Authentication Input OTPA two-factor sign-in screen with an
- Auto-submit OTP Input OTPA one-time code form that submits on its