Faber UI
Components

InputOTP

An accessible one-time password input.

InputOTP is built on input-otp. It renders an accessible one-time password input with grouped slots and an optional separator.

Installation

Terminal
pnpm dlx shadcn@latest add https://faber-ui.vercel.app/r/input-otp.json

Usage

typescript
"use client";

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

export default function Example() {
  return (
    <InputOTP maxLength={6}>
      <InputOTPGroup>
        <InputOTPSlot index={0} />
        <InputOTPSlot index={1} />
        <InputOTPSlot index={2} />
      </InputOTPGroup>
    </InputOTP>
  );
}

Examples

Default

With separator

API

Each part forwards every prop of what it is built on, including className and render where Base UI supports it. The props column lists only what Faber UI adds on top.

PartBuilt onProps
InputOTPdata-slot="input-otp"OTPInputinput-otp
  • containerClassName?string
InputOTPGroupdata-slot="input-otp-group"<div>HTML—
InputOTPSlotdata-slot="input-otp-slot"<div>HTML
  • indexnumber
InputOTPSeparatordata-slot="input-otp-separator"<div>HTML—

Changelog

  1. v0.3.0KbdGroup is typed as a kbd element, Combobox imports its Base UI subpath, the motion lib mirrors the exit easing and travel tokens, and the chart item declares its react-is peer.patch
Full InputOTP history

Last updated on

On this page