EXAMPLE SCREENS
Verify email
One-time-code entry with a resend countdown. Paste 123456 and every box fills at once, then it verifies itself.
PREVIEW
SOURCE
import { AuthShell, AuthCard, OtpInput, Field, Alert } from '@objectifthunes/whiteboard'
<Field label="Verification code" hint="We sent a 6-digit code to your email.">
<OtpInput
value={code}
onChange={setCode}
onComplete={verify} // fires when the last box fills — no click needed
invalid={state === 'bad'}
autoFocus
/>
</Field>
<Button
fullWidth
disabled={code.replace(/\s/g, '').length < 6}
loading={state === 'checking'}
onClick={() => verify(code)}
>
Verify email
</Button>
<Button variant="secondary" disabled={cooldown > 0} onClick={() => setCooldown(30)}>
{cooldown > 0 ? `Resend in ${cooldown}s` : 'Resend code'}
</Button>NOTES
OtpInput keeps the whole code in one string, so it is one form value. Paste 123456 and every box fills at once — dropping all but the first character is the failure that makes these fields infuriating.
Entering the last digit fires onComplete and verifies without a click. The resend button runs a 30 second cooldown.