Skip to content

PinInput

PinInput

{/* SMS verification code */}
<PinInput
length={6}
label="Verification code"
description="Sent to +82 ····-1234"
autoFocus
onComplete={async (code) => { await verify(code); }}
/>
{/* Masked 4-digit PIN */}
<PinInput length={4} mask label="Enter PIN" />

Install: @helixui/core

import { PinInput } from '@helixui/core'

status: stable · since: 0.5.0

Tags: otp, pin, verification, sms

Anatomy

[ _ ][ _ ][ _ ][ _ ][ _ ][ _ ] ← 6-digit code

Layout

  • displayinline-flex
  • widthcontent
  • heightcontent
  • intrinsicSize~44-56px tall, hugs N cells
  • stackablefalse
  • fullBleedfalse

Visual

A row of single-character cells with auto-advance, paste-to-fill, backspace-to-previous, and SMS one-time-code autofill on iOS/Android.

Props

NameTypeDefaultDescription
lengthnumber6Number of cells.
valuestringControlled value.
defaultValuestringUncontrolled initial.
onChange(value: string) => voidChange handler.
onComplete(value: string) => voidCalled once when the last cell is filled.
pattern'digits' | 'alphanumeric'digitsAllowed character set.
maskbooleanfalseMask the value (for PINs).
isInvalidbooleanfalseInvalid styling.
isDisabledbooleanfalseDisable all cells.
labelReactNodeLabel above the cells.
descriptionReactNodeHelper text.
errorMessageReactNodeError text. Implies isInvalid.
size'sm' | 'md' | 'lg'mdCell size.
autoFocusbooleanfalseFocus the first cell on mount.

Tokens used

color.bg.surface.default, color.bg.surface.muted, color.bg.action.brand.default, color.border.default, color.border.focus, color.border.danger, color.text.primary, color.text.secondary, color.text.action.danger, radius.md, space.2, font.family.sans, font.size.sm, font.size.md, font.size.xl, font.size.2xl, font.weight.medium, font.weight.semibold

Accessibility

Notes

  • First cell has autocomplete="one-time-code" so iOS / Android can offer SMS code autofill.
  • inputMode="numeric" on digit-only mode brings up the numeric keypad on mobile.
  • Error message has role="alert".

Composes with

ComponentRelationNote
NumericKeypadsiblingPair on mobile when system keyboard is undesired.
FieldwrapsWrap with Field for label/error.
TextInputsibling
Steppersibling

Prompt examples

These are the AI prompt → JSX mappings used by the helixui prompt DSL and integrations like Cursor / Claude Code.

verify SMS code

“6-digit OTP input”

<PinInput length={6} value={code} onChange={setCode} />