A verification code is six slots in shadcn, so plan paste and submit
A verification-code field looks like one input. In shadcn it is an InputOTP built from slots, and the paste behavior comes with the component, so the real work is in the submit and resend steps. What the shadcn page covers The page describes the component as "Accessible one-time password component with copy-paste functionality." The install command is pnpm dlx shadcn@latest add input-otp , with…
The verification-code field in shadcn is an accessible one-time password component with copy-paste functionality. The install command is pnpm dlx shadcn@latest add input-otp, and the component can be imported from "@/components/ui/input-otp". To use the component, import InputOTP, InputOTPGroup, InputOTPSeparator, and InputOTPSlot. Set maxLength={6} on the root InputOTP component.
The component can be built with various patterns, including a digits-only pattern using the REGEXP_ONLY_DIGITS regex. The code should be six digits, divided into two groups of three with a separator in between. Use InputOTPSlot components with indices from 0 to 5 to create the groups. The separator is purely visual, and the root's maxLength property determines when the field is full.
To control the input, use the value and onChange props with React state. The form can then check the code before submission. A Verify button should be disabled until six characters are present. The component can also display errors on slots by setting aria-invalid when the server rejects the code. Clear the error when the user edits the field again.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.