Uai

authenticationcode-verification.tsx

Color theme

block · 46/108

Code Verification

One-time code entry with paste, resend timing, errors, and alternate methods.

Install

Install manuallyView source on GitHub

Composes

  • code-verification.tsx13
  • inline-feedback.tsx2
  • status-banner.tsx2

Accessibility4 checks

  • Each box is a labelled input inside a named group; the first carries autocomplete="one-time-code" so browsers and phones can autofill the whole code.
  • Typing advances, Backspace steps back, Left, Right, Home, and End move between boxes, and pasting fills every box at once.
  • Invalid and expired codes mark the boxes with aria-invalid, render as an alert Status Banner, and return focus to the first box.
  • The resend button stays disabled during the countdown and shows the remaining time in text; its result is announced through Inline Feedback.
canvasvariant="card"authentication
Authentication and onboarding

Check your email

We sent a 6-digit code to marta@larkspur.example. It expires in 10 minutes. Try 482913, or 000000 for an expired code.

Can’t get the email?
code verification variant

Code example

usage.tsx
"use client";import {  CodeVerification,  CodeVerificationAlternative,  CodeVerificationAlternatives,  CodeVerificationDescription,  CodeVerificationDestination,  CodeVerificationForm,  CodeVerificationHeader,  CodeVerificationInput,  CodeVerificationMessage,  CodeVerificationResend,  CodeVerificationResendButton,  CodeVerificationSubmit,  CodeVerificationTitle,  type CodeVerificationVariant,} from "@/components/uai/code-verification";import { InlineFeedbackMessage, InlineFeedbackStatus } from "@/components/ui/uai/inline-feedback";import { StatusBannerDescription, StatusBannerTitle } from "@/components/ui/uai/status-banner";async function checkCode(code: string) {  await new Promise((resolve) => setTimeout(resolve, 600));  if (code === "000000") return "expired" as const;  return code === "482913" ? ("success" as const) : ("invalid" as const);}async function sendNewCode() {  await new Promise((resolve) => setTimeout(resolve, 500));}export function CodeVerificationPreview({  variant = "card",}: {  variant?: CodeVerificationVariant;}) {  return (    <CodeVerification      variant={variant}      onVerify={checkCode}      onResend={sendNewCode}      resendAfter={30}    >      <CodeVerificationHeader>        <CodeVerificationTitle>Check your email</CodeVerificationTitle>        <CodeVerificationDescription>          We sent a 6-digit code to{" "}          <CodeVerificationDestination>marta@larkspur.example</CodeVerificationDestination>. It          expires in 10 minutes. Try 482913, or 000000 for an expired code.        </CodeVerificationDescription>      </CodeVerificationHeader>      <CodeVerificationForm>        <CodeVerificationInput label="6-digit code" />        <CodeVerificationMessage status="invalid">          <StatusBannerTitle>That code doesn’t match</StatusBannerTitle>          <StatusBannerDescription>Check the latest email and try again.</StatusBannerDescription>        </CodeVerificationMessage>        <CodeVerificationMessage status="expired">          <StatusBannerTitle>This code has expired</StatusBannerTitle>          <StatusBannerDescription>Request a new code to continue.</StatusBannerDescription>        </CodeVerificationMessage>        <CodeVerificationMessage status="verified">          <StatusBannerTitle>Email verified</StatusBannerTitle>          <StatusBannerDescription>Taking you to your workspace…</StatusBannerDescription>        </CodeVerificationMessage>        <CodeVerificationSubmit>Verify email</CodeVerificationSubmit>        <CodeVerificationResend>          <CodeVerificationResendButton>Resend code</CodeVerificationResendButton>          <InlineFeedbackStatus>            <InlineFeedbackMessage status="success">New code sent</InlineFeedbackMessage>            <InlineFeedbackMessage status="error">Couldn’t send. Try again.</InlineFeedbackMessage>          </InlineFeedbackStatus>        </CodeVerificationResend>        <CodeVerificationAlternatives>          <span>Can’t get the email?</span>          <CodeVerificationAlternative>Text me instead</CodeVerificationAlternative>          <CodeVerificationAlternative>Use a backup code</CodeVerificationAlternative>        </CodeVerificationAlternatives>      </CodeVerificationForm>    </CodeVerification>  );}

Manual installation

code-verification.tsx

Loading component source…

esc
ThinkingAI
MessageAI
CitationAI
AttachmentAI
Tool CallAI
Response StatusAI
Run SummaryAI
Conversation ThreadAI · Block
Research SessionAI · Block
File AnalysisAI · Block
Agent RunAI · Block
Approval CardFeedback
Empty StateFeedback
Status BannerFeedback
Progress SummaryFeedback
Inline FeedbackFeedback
Confirmation DialogFeedback
Activity TimelineFeedback
Skeleton GroupFeedback
Prompt ComposerForms
Form FieldForms
Search FieldForms
Filter BarForms
File UploadForms
Date Range PickerForms
Form Error SummaryForms
Unsaved Changes BarForms
Step IndicatorForms
Task ListData Display
Data Table ToolbarData Display
Metric CardData Display
Description ListData Display
Comparison TableData Display
Kanban BoardData Display
Calendar ViewData Display
Audit LogData Display
App HeaderNavigation
App SidebarNavigation
Breadcrumb TrailNavigation
Page TabsNavigation
Command MenuNavigation
Split PaneNavigation
Sign-in CardAuthentication
Sign-up CardAuthentication
Password RecoveryAuthentication
Code VerificationAuthentication · Block
Onboarding WizardAuthentication · Block
Workspace SetupAuthentication · Block
Coupon FieldCommerce
Quantity PickerCommerce
Cart ItemCommerce
Price SummaryCommerce
Order StatusCommerce
Product DetailCommerce · Block
Product ListingCommerce · Block
Cart DrawerCommerce · Block
CheckoutCommerce · Block
Order TrackingCommerce · Block
Subscription ManagementCommerce · Block
Announcement BarMarketing
Pricing ToggleMarketing
Testimonial CardMarketing
Product GalleryMarketing
Trust PanelMarketing
Newsletter FormMarketing
Hero SectionMarketing · Block
Feature ShowcaseMarketing · Block
Pricing SectionMarketing · Block
Testimonials SectionMarketing · Block
FAQ SectionMarketing · Block
Call to ActionMarketing · Block
Waitlist SectionMarketing · Block
Contact SectionMarketing · Block
Author CardContent
CommentContent
Reaction BarContent
Share MenuContent
Changelog EntryContent
Article PageContent · Block
Documentation PageContent · Block
Changelog PageContent · Block
Comment ThreadContent · Block
Community FeedContent · Block
Public ProfileContent · Block
Map FrameMaps
Map ControlsMaps
Map MarkerMaps
Map LegendMaps
Place CardMaps
Route SummaryMaps
Dashboard ShellApplication · Block
Settings PageApplication · Block
Profile PageApplication · Block
Team ManagementApplication · Block
Notification CenterApplication · Block
Billing PortalApplication · Block
Search ResultsApplication · Block
Resource ManagerOperations · Block
Data ExplorerOperations · Block
Import WorkflowOperations · Block
Approval QueueOperations · Block
Audit Log ViewerOperations · Block
Incident DashboardOperations · Block
Report BuilderOperations · Block
Document FieldBrazil
CEP FieldBrazil
Pix PaymentBrazil
Installment PickerBrazil