Input OTP

A one-time password input component with animated slots and customizable separators.

Overview

The InputOTP component provides a user-friendly interface for entering one-time passwords or verification codes. It features animated character slots, customizable grouping with separators, and supports validation states.

Usage

import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from "@tilt-legal/cubitt-components/primitives";
<InputOTP maxLength={6}>
  <InputOTPGroup>
    <InputOTPSlot index={0} />
    <InputOTPSlot index={1} />
    <InputOTPSlot index={2} />
  </InputOTPGroup>
  <InputOTPSeparator />
  <InputOTPGroup>
    <InputOTPSlot index={3} />
    <InputOTPSlot index={4} />
    <InputOTPSlot index={5} />
  </InputOTPGroup>
</InputOTP>

Examples

Basic

A basic OTP input with two groups separated by a dash.

With Multiple Separators

OTP input with multiple groups and separators for credit card-style formatting.

Numbers Only

OTP input restricted to numeric characters only using a regex pattern.

Invalid State

OTP input showing an invalid/error state.

Disabled

OTP input in a disabled state.


API Reference

InputOTP

The root component that manages the OTP input state. Built on input-otp.

PropTypeDefaultDescription
maxLengthnumber-Maximum number of characters (required)
valuestring-Controlled value
onChange(value: string) => void-Callback when value changes
onComplete(value: string) => void-Callback when all slots are filled
patternstring-Regex pattern for allowed characters
invalidbooleanfalseShows invalid/error styling on all slots
disabledbooleanfalseDisables the input
containerClassNamestring-Class name for the container element

InputOTPGroup

Groups slots together visually.

PropTypeDefaultDescription
classNamestring-Additional CSS classes

InputOTPSlot

Individual character slot that displays a single character.

PropTypeDefaultDescription
indexnumber-Slot position index (required)
classNamestring-Additional CSS classes

InputOTPSeparator

Visual separator between slot groups.

PropTypeDefaultDescription
classNamestring-Additional CSS classes

On this page