Skip to content
coatx
Esc
↑↓navigate↵open⌘Jpreview
On this page

Input OTP

Accessible one-time passcode slot recipes pairing with @ilha/ui-sdk/otp-input.

Usage

import {
  OTPInput,
  OTPInputGroup,
  OTPInputSeparator,
  OTPInputSlot,
} from "@ilha/ui-sdk/otp-input";
import {
  inputOtp,
  inputOtpGroup,
  inputOtpSeparator,
  inputOtpSlot,
} from "coatx/input-otp";

export const VerifyCode = () => (
  <OTPInput maxLength={6} aria-label="Verification code" {...inputOtp()}>
    <OTPInputGroup {...inputOtpGroup()}>
      <OTPInputSlot
        index={0}
        class={(s) => inputOtpSlot({ active: s.active }).class}
      />
      <OTPInputSlot
        index={1}
        class={(s) => inputOtpSlot({ active: s.active }).class}
      />
      <OTPInputSlot
        index={2}
        class={(s) => inputOtpSlot({ active: s.active }).class}
      />
    </OTPInputGroup>
    <OTPInputSeparator {...inputOtpSeparator()}>-</OTPInputSeparator>
    <OTPInputGroup {...inputOtpGroup()}>
      <OTPInputSlot
        index={3}
        class={(s) => inputOtpSlot({ active: s.active }).class}
      />
      <OTPInputSlot
        index={4}
        class={(s) => inputOtpSlot({ active: s.active }).class}
      />
      <OTPInputSlot
        index={5}
        class={(s) => inputOtpSlot({ active: s.active }).class}
      />
    </OTPInputGroup>
  </OTPInput>
);

Exports (coatx/input-otp)

Export Description
inputOtp(options?) Root OTP input wrapper
inputOtpGroup(options?) Connected group of character slots
inputOtpSlot(options?) Individual slot box (active, invalid, disabled)
inputOtpSeparator(options?) Visual divider between slot groups
inputOtpCaret(options?) Reduced-motion-aware blinking caret bar
inputOtpStyles Compiled StyleX style map

Was this page helpful?