Skip to content
All components
Forms

Input OTP

Enter a short one-time verification code across separate character slots, with paste, autofill and keyboard movement handled.

One-time code entry, with paste across slots handled.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add input-otp

Then import it from @/components/ui/input-otp. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Six digits

Enter a six-digit code across separated slots named by one group label. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import { InputOTP, InputOTPSeparator, InputOTPSlot } from "@/components/ui/input-otp"

export function InputOtpSixDigits() {
  
  

  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <InputOTP aria-label="Verification code">
        <InputOTPSlot />
        <InputOTPSlot />
        <InputOTPSlot />
        <InputOTPSeparator />
        <InputOTPSlot />
        <InputOTPSlot />
        <InputOTPSlot />
      </InputOTP>
    </div>
  )
}

With hint

Label the code with visible text, explain where it came from and submit it with a hidden input. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { FieldDescription } from "@/components/ui/field"
import {
  InputOTP,
  InputOTPHiddenInput,
  InputOTPSeparator,
  InputOTPSlot,
} from "@/components/ui/input-otp"

export function InputOtpWithHint() {
  const id = React.useId()
  

  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <div className="flex flex-col gap-1.5">
        <p id={`${id}-sms-label`} className="text-label-sm text-strong-950">Code from your text message</p>
        <InputOTP
          aria-labelledby={`${id}-sms-label`}
          aria-describedby={`${id}-sms-hint`}
          name="sms-code"
        >
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSeparator />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPHiddenInput />
        </InputOTP>
        <FieldDescription id={`${id}-sms-hint`}>
          We sent a 6-digit code to the number ending in 42. You can paste it into the first box.
        </FieldDescription>
      </div>
    </div>
  )
}

Invalid

Mark the slots invalid and associate an error that says how to recover. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { FieldError } from "@/components/ui/field"
import { InputOTP, InputOTPSeparator, InputOTPSlot } from "@/components/ui/input-otp"

export function InputOtpInvalid() {
  const id = React.useId()
  

  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <div className="flex flex-col gap-1.5">
        <p id={`${id}-error-label`} className="text-label-sm text-strong-950">Sign-in code</p>
        <InputOTP
          aria-labelledby={`${id}-error-label`}
          aria-describedby={`${id}-error-message`}
          defaultValue="482913"
        >
          <InputOTPSlot aria-invalid className="aria-invalid:border-error-base" />
          <InputOTPSlot aria-invalid className="aria-invalid:border-error-base" />
          <InputOTPSlot aria-invalid className="aria-invalid:border-error-base" />
          <InputOTPSeparator />
          <InputOTPSlot aria-invalid className="aria-invalid:border-error-base" />
          <InputOTPSlot aria-invalid className="aria-invalid:border-error-base" />
          <InputOTPSlot aria-invalid className="aria-invalid:border-error-base" />
        </InputOTP>
        <FieldError id={`${id}-error-message`}>
          That code has expired. Request a new one and enter it within 10 minutes.
        </FieldError>
      </div>
    </div>
  )
}

Disabled

Inspect the unavailable control using its real disabled semantics. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { FieldDescription } from "@/components/ui/field"
import { InputOTP, InputOTPSeparator, InputOTPSlot } from "@/components/ui/input-otp"

export function InputOtpDisabled() {
  const id = React.useId()
  

  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <div className="flex flex-col gap-1.5">
        <p id={`${id}-off-label`} className="text-label-sm text-strong-950">Authenticator code</p>
        <InputOTP aria-labelledby={`${id}-off-label`} aria-describedby={`${id}-off-hint`} disabled>
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSeparator />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
        </InputOTP>
        <FieldDescription id={`${id}-off-hint`}>
          Available after you set up an authenticator app.
        </FieldDescription>
      </div>
    </div>
  )
}

Read only

Keep code slots readable while preventing changes. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { FieldDescription } from "@/components/ui/field"
import { InputOTP, InputOTPSeparator, InputOTPSlot } from "@/components/ui/input-otp"

export function InputOtpReadOnly() {
  const id = React.useId()
  

  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <div className="flex flex-col gap-1.5">
        <p id={`${id}-read-label`} className="text-label-sm text-strong-950">Pairing code</p>
        <InputOTP aria-labelledby={`${id}-read-label`} aria-describedby={`${id}-read-hint`} defaultValue="731905" readOnly>
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSeparator />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
        </InputOTP>
        <FieldDescription id={`${id}-read-hint`}>
          Enter this code on the device you want to pair.
        </FieldDescription>
      </div>
    </div>
  )
}

Alphanumeric

Accept letters and numbers for a longer recovery code. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { FieldDescription } from "@/components/ui/field"
import { InputOTP, InputOTPSeparator, InputOTPSlot } from "@/components/ui/input-otp"

export function InputOtpAlphanumeric() {
  const id = React.useId()
  

  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <div className="flex flex-col gap-1.5">
        <p id={`${id}-recovery-label`} className="text-label-sm text-strong-950">Recovery code</p>
        <InputOTP
          aria-labelledby={`${id}-recovery-label`}
          aria-describedby={`${id}-recovery-hint`}
          validationType="alphanumeric"
        >
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSeparator />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
        </InputOTP>
        <FieldDescription id={`${id}-recovery-hint`}>
          8 letters or numbers from the list you saved when you turned on two-step sign-in.
        </FieldDescription>
      </div>
    </div>
  )
}

Auto submit

Submit the surrounding form once every slot is filled, with compact slots for narrow screens. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import * as React from "react"

import { FieldDescription } from "@/components/ui/field"
import { InputOTP, InputOTPHiddenInput, InputOTPSlot } from "@/components/ui/input-otp"

export function InputOtpAutoSubmit() {
  const id = React.useId()
  const [status, setStatus] = React.useState<string | null>(null)

  return (
    <div className="flex w-full max-w-sm flex-col gap-8">
      <form
        className="flex flex-col gap-1.5"
        onSubmit={(event) => {
          event.preventDefault()
          setStatus("Checking the code…")
        }}
      >
        <p id={`${id}-auto-label`} className="text-label-sm text-strong-950">Email code</p>
        <InputOTP
          aria-labelledby={`${id}-auto-label`}
          aria-describedby={`${id}-auto-hint`}
          name="email-code"
          autoSubmit
          className="gap-1.5"
        >
          <InputOTPSlot className="size-10" />
          <InputOTPSlot className="size-10" />
          <InputOTPSlot className="size-10" />
          <InputOTPSlot className="size-10" />
          <InputOTPSlot className="size-10" />
          <InputOTPSlot className="size-10" />
          <InputOTPHiddenInput />
        </InputOTP>
        <FieldDescription id={`${id}-auto-hint`}>
          Sends the code as soon as all 6 digits are entered.
        </FieldDescription>
        <p role="status" className="text-paragraph-sm text-sub-600">{status}</p>
      </form>
    </div>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

InputOTP

Built on the Radix one-time-password field rather than a separate package: it already handles paste across slots, arrow keys and autocomplete.

InputOTP props
PropTypeDefaultDescription
formstring | undefined—A string specifying the form element with which the input is associated. This string's value, if present, must match the id of a form element in the same document.
defaultValuestring | undefined—The initial value of the uncontrolled field.
autoFocusboolean | undefined—Whether or not the first fillable input should be focused on page-load.
dir("ltr" | "rtl") | undefined—Indicates the horizontal directionality of the parent element's text.
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
disabledboolean | undefined—Whether or not the field's input elements are disabled.
namestring | undefined—A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted.
type("text" | "password") | undefined—The input type of the field's input elements. Can be "password" or "text".
valuestring | undefined—The controlled value of the field.
orientation("horizontal" | "vertical") | undefined—Indicates the vertical directionality of the input elements.
autoComplete("off" | "one-time-code") | undefined—Specifies what—if any—permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field. Allows "one-time-code" or "off".
placeholderstring | undefined—Defines the text displayed in a form control when the control has no value.
readOnlyboolean | undefined—Whether or not the input elements can be updated by the user.
autoSubmitboolean | undefined—Whether or not the component should attempt to automatically submit when all fields are filled. If the field is associated with an HTML form element, the form's requestSubmit method will be called.
onAutoSubmit((value: string) => void) | undefined—When the autoSubmit prop is set to true, this callback will be fired before attempting to submit the associated form. It will be called whether or not a form is located, or if submission is not allowed.
onValueChange((value: string) => void) | undefined—A callback fired when the field's value changes. When the component is controlled, this should update the state passed to the value prop.
sanitizeValue((value: string) => string) | undefined—Function for custom sanitization when validationType is set to "none". This function will be called before updating values in response to user interactions.
validationTypeOneTimePasswordField.InputValidationType | undefined—Specifies the type of input validation to be used. Can be "alpha", "numeric", "alphanumeric" or "none".
Inherited props (12)
InputOTP inherited props
PropTypeDefaultDescription
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

InputOTPHiddenInput

The InputOTPHiddenInput part of input-otp. Use it with the complete source composition and preserve its required parent context.

InputOTPHiddenInput props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (25)
InputOTPHiddenInput inherited props
PropTypeDefaultDescription
formstring | undefined—ID of the form associated with this control, including when it is rendered outside that form element.
patternstring | undefined—Native input validation pattern. Provide readable format guidance and associated validation feedback.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLInputElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLInputElement> | undefined—Receive the native blur event when focus leaves this control.
onKeyDownReact.KeyboardEventHandler<HTMLInputElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLInputElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLInputElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
altstring | undefined—Text alternative for the image. Identify informative images; use an empty alternative only when the image is genuinely decorative.
srcstring | undefined—Image source URL. Supply alternative text appropriate to whether the image conveys identity or is decorative.
namestring | undefined—Name used by the control's form submission or primitive form integration.
valuestring | number | readonly string[] | undefined—Current value in the shape defined by the source type. For controlled interactive inputs, apply updates from the change callback.
multipleboolean | undefined—Allow multiple values where the native element or primitive supports them, using its source-defined value shape.
checkedboolean | undefined—Current checked state. Apply the requested value from onCheckedChange when the parent owns this state.
maxstring | number | undefined—Maximum supported numeric value.
maxLengthnumber | undefined—Maximum allowed text length for native input or code entry.
minstring | number | undefined—Minimum supported numeric value.
minLengthnumber | undefined—Minimum allowed text length for native validation.
placeholderstring | undefined—Prompt shown before a value is selected or entered. Supply an accessible label separately.
requiredboolean | undefined—Mark this control as required using its native or primitive semantics. Consumers own contextual validation feedback.
stepstring | number | undefined—Numeric increment used for slider or native input changes.
refReact.Ref<HTMLInputElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

InputOTPSeparator

Visual or semantic separation between adjacent items. It is not an operable item.

InputOTPSeparator props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
InputOTPSeparator inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLDivElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLDivElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLDivElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLDivElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLDivElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLDivElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

InputOTPSlot

The InputOTPSlot part of input-otp. Use it with the complete source composition and preserve its required parent context.

InputOTPSlot props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
onInvalidChange((character: string) => void) | undefined—Callback fired when the user input fails native HTML input validation.
indexnumber | undefined—User-provided index to determine the order of the inputs. This is useful if you need certain index-based attributes to be set on the initial render, often to prevent flickering after hydration.
Inherited props (23)
InputOTPSlot inherited props
PropTypeDefaultDescription
patternstring | undefined—Native input validation pattern. Provide readable format guidance and associated validation feedback.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLInputElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLInputElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLInputElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLInputElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLInputElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.
asChildboolean | undefined—Merge this part into one child instead of its default element. Preserve that child's semantics, ref support and accessibility attributes.
altstring | undefined—Text alternative for the image. Identify informative images; use an empty alternative only when the image is genuinely decorative.
srcstring | undefined—Image source URL. Supply alternative text appropriate to whether the image conveys identity or is decorative.
multipleboolean | undefined—Allow multiple values where the native element or primitive supports them, using its source-defined value shape.
checkedboolean | undefined—Current checked state. Apply the requested value from onCheckedChange when the parent owns this state.
maxstring | number | undefined—Maximum supported numeric value.
maxLengthnumber | undefined—Maximum allowed text length for native input or code entry.
minstring | number | undefined—Minimum supported numeric value.
minLengthnumber | undefined—Minimum allowed text length for native validation.
requiredboolean | undefined—Mark this control as required using its native or primitive semantics. Consumers own contextual validation feedback.
stepstring | number | undefined—Numeric increment used for slider or native input changes.
refReact.Ref<HTMLInputElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

Accessibility & usage

From registry/ui/input-otp.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • Verification codes sent by text message, email or an authenticator app.
  • Recovery or pairing codes of a fixed, short length.

When not to use

  • Passwords, PINs that people choose, card numbers or any value of variable length.
  • Codes longer than about 8 characters, where one Input with a format hint is easier to correct.

Anatomy

InputOTP
The Radix one-time password root, rendered as a group. Takes the accessible name, aria-describedby, value, validationType, autoSubmit, name, disabled and readOnly.
InputOTPSlot
One character input with its own 'Character n of total' label; 44 CSS px square by default.
InputOTPSeparator
A decorative divider between slot groups; not focusable.
InputOTPHiddenInput
A hidden input that carries the joined value for native form submission.

Keyboard & interaction

  • Typing moves to the next slot; Backspace clears and moves back; arrow keys move between slots.
  • Pasting a full code into any slot replaces the value and fills the slots from the first one.
  • autoComplete defaults to one-time-code, so platforms can offer a code received by text message.
  • validationType defaults to numeric (with a numeric on-screen keyboard); use alphanumeric or alpha for codes that contain letters.
  • With autoSubmit the surrounding form is submitted once every slot is filled; announce the result in a status message.

Responsive behavior

  • Six 44 CSS px slots with a separator and gaps take about 320 CSS px, more than a 320 px screen leaves inside its margins; on narrow screens use slightly smaller slots, a smaller gap or no separator so the row does not overflow.
  • Keep slots at least 24x24 CSS px; 40 to 44 px is easier on touch screens.
  • Keep the hint and error below the group so they stay in view when the on-screen keyboard opens.

Content guidelines

  • Label: say where the code comes from ('Code from your text message').
  • Hint: where it was sent and its length ('We sent a 6-digit code to the number ending in 42').
  • Error: what happened and the next step ('That code has expired. Request a new one').
  • Offer a visible way to resend the code next to the field.

Alternatives

  • Input — Variable-length values, passwords and long codes.
  • Field — Hint and error text associated with the code group.

Resources