shadcn.io is an independent project built on shadcn/ui
Three labeled fields stack on the page. 4-Digit OTP is four boxes. 6-Digit OTP is two groups of three. 8-Digit OTP is two groups of four.
Match the length to the code you send. A single Input is easier when the length is not fixed. In Svelte, Ark UI moves to the next box as you type.
Installation
Anatomy

Usage
<div class="flex flex-col gap-6"><Field><FieldLabel>4-Digit OTP</FieldLabel><InputOTP><InputOTPGroup><InputOTPSlot class="bg-background" index={0} /><InputOTPSlot class="bg-background" index={1} /><InputOTPSlot class="bg-background" index={2} /><InputOTPSlot class="bg-background" index={3} /></InputOTPGroup></InputOTP></Field><Field><FieldLabel>6-Digit OTP</FieldLabel><InputOTP><InputOTPGroup><InputOTPSlot class="bg-background" index={0} /><InputOTPSlot class="bg-background" index={1} /><InputOTPSlot class="bg-background" index={2} /></InputOTPGroup><InputOTPSeparator /><InputOTPGroup><InputOTPSlot class="bg-background" index={3} /><InputOTPSlot class="bg-background" index={4} /><InputOTPSlot class="bg-background" index={5} /></InputOTPGroup></InputOTP></Field><Field><FieldLabel>8-Digit OTP</FieldLabel><InputOTP><InputOTPGroup><InputOTPSlot class="bg-background" index={0} /><InputOTPSlot class="bg-background" index={1} /><InputOTPSlot class="bg-background" index={2} /><InputOTPSlot class="bg-background" index={3} /></InputOTPGroup><InputOTPSeparator /><InputOTPGroup><InputOTPSlot class="bg-background" index={4} /><InputOTPSlot class="bg-background" index={5} /><InputOTPSlot class="bg-background" index={6} /><InputOTPSlot class="bg-background" index={7} /></InputOTPGroup></InputOTP></Field></div>FAQ
How should I group each length?
Short codes read best in one block. Split longer ones in the middle, as here: three and three for six digits, four and four for eight, with an InputOTPSeparator between the groups.
How do the indexes work in the eight-digit field?
They count through the whole code, 0 to 7: 0 to 3 in the first group and 4 to 7 in the second.
How is each field labeled?
Each sits in its own Field with a FieldLabel: 4-Digit OTP, 6-Digit OTP and 8-Digit OTP.
Field links each label to its code field.
API Reference
Field
No extra props in this demo. The rest is on the Field page.
Input OTP
Sets index={0}, index={1}, index={2}, index={3}, index={4} and index={5}. The rest is on the Input OTP page.





