Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Inputs

OTP Input

Inputs

OTP Input React component for Tailwind CSS v4

Number InputPassword Input
Live props
Behavior
length6
type
mask
autoFocus
Appearance
size
radius
surface
textColor
successColor
errorColor
State
status
disabled
defaultValue
Content
slotLabel
Code
import OtpInput from "@/components/ui/otp-input"

<OtpInput />
  1. Home
  2. Components
  3. Inputs
  4. OTP Input
Free

OTP Input React component for Tailwind CSS v4

v1.0.1·Updated in 1.2.1

A React OTP input for one-time verification codes and PINs, with digits that roll into place and a caret that slides between slots.

Type to fill each slot and move to the next one. Backspace clears a slot in place, then steps back on the next press. Arrow keys move between slots, and a caret slides along with you. Pasting a code, or letting the phone autofill one from a text message, drops it straight in. Set the status to turn the slots green, or shake them red on a wrong code.

OTP Input is a free React component in the React input components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add otp-input, together with UIProvider and the npm package motion.

Add to a project

Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add otp-input

Usage

Import OtpInput from @/components/ui/otp-input.

import { useState } from "react"
import OtpInput, { type OtpStatus } from "@/components/ui/otp-input"

export function Demo() {
  const [status, setStatus] = useState<OtpStatus>("idle")

  return (
    <OtpInput
      length={6}
      size="md"
      status={status}
      onChange={() => setStatus("idle")}
      onComplete={(code) => setStatus(checkCode(code) ? "success" : "error")}
    />
  )
}

Props

  • lengthdefault 6
    number

    How many boxes to render, so a 4 digit code is length={4}. Any count works.

  • sizedefault "md"
    "sm" | "md" | "lg"

    Overall scale of the boxes. Maps to 40px (sm, 44px on touch screens), 48px (md), and 56px (lg), and carries the text, caret, and gaps with it. In a container narrower than the row, the boxes shrink evenly and stay square, so 8 slots still fit a 360px phone.

  • typedefault "numbers"
    "numbers" | "letters" | "both"

    Which characters a slot accepts. Anything else is ignored, including on paste.

  • statusdefault "idle"
    "idle" | "success" | "error"

    Drives the feedback state. Success traces a green ring around each box in turn, error rings them red and shakes the row once.

  • radiusdefault "md"
    "none" | "sm" | "md" | "lg" | "full"

    Slot corners as a share of the slot, so they shrink with it and match the success ring: square, half, the original 20 / 25 / 29% per size, rounder, or circles.

  • surfacedefault ""
    string

    Any CSS color for the slot fill. Empty uses #F4F4F9 light, #262626 dark.

  • textColordefault ""
    string

    Any CSS color for the characters and the caret. Empty is black on light pages, white on dark ones.

  • successColordefault "#34C759"
    string

    Any CSS color for the ring drawn around each slot on success.

  • errorColordefault "#FF3B30"
    string

    Any CSS color for the ring shown on error.

  • maskdefault false
    boolean

    Hides the characters, like a password field.

  • disableddefault false
    boolean

    Blocks input and dims every slot.

  • autoFocusdefault false
    boolean

    Focuses the first slot on mount.

  • slotLabeldefault ""
    string

    Accessible name template for each slot; {index} and {length} fill in, e.g. "Cifra {index} din {length}". Empty reads "Digit 1 of 6" (or "Character" for letters).

  • value
    string

    The current code. Pass it to control the input yourself; leave it out to let the component track its own state.

  • defaultValuedefault ""
    string

    Starting code when the input is uncontrolled.

  • onChange
    (value: string) => void

    Fires on every edit with the full code so far.

  • onComplete
    (value: string) => void

    Fires once the last slot is filled.

  • className
    string

    Extra classes for the row that wraps the slots.

  • slotClassName
    string

    Extra classes for each slot, for sizing and colors.

Examples

Verify a phone number

A sign-in step with a controlled value, a Verify button, a resend link and a live message.

Sizes

sm, md and lg. On a narrow screen the slots shrink evenly and stay square.

Success, error and disabled

status rings each slot green or red; error also shakes the row once.

Masked PIN

mask hides the digits, radius full makes round slots, slotLabel names each one for screen readers.

Backup code

type both accepts letters and digits, here in eight small slots.

Dependencies

motionui-config

Files

  • components/ui/otp-input.tsx

FAQ

Is the React OTP Input component free?

Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.

How do I install OTP Input?

Run npx wingo-ui@latest add otp-input. It also adds the Wingo UI item it builds on (UIProvider) and the npm package motion. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/otp-input.json.

See also

Masked InputPassword InputInputFieldLogin Page

Used in

Login PageRegister PageSettings Page

More React input components

Avatar UploadColor PickerCalendarSliderSwitchSegmented Control
All 40 React input components

Articles using this component

  • Shadcn Login Page: Magic Link, Codes, 2FA and Recovery

    Build it: screens and apps · Oct 16, 2026 · 11 min read

  • React Form Components: Accessible Fields, Zod and Mobile

    Component guides · Oct 9, 2026 · 26 min read

  • React OTP Input: Paste, SMS Autofill and a Resend Timer

    Component guides · Oct 9, 2026 · 11 min read

PreviousNumber InputNext Password Input

Enter 123456 to pass. Any other code fails.