Input OTP
Collects a one-time code in a segmented input.
Installation
Install Input OTP from Oros with shadcn CLI 4.13.0.
pnpm dlx shadcn@4.13.0 add @oros/input-otpUsage
import {
InputOTP,
InputOTPGroup,
InputOTPSlot,
InputOTPSeparator,
} from "@/components/ui/input-otp"Open the Source tab in the preview for a complete working example.
Anatomy
| Export | Responsibility |
|---|---|
| InputOTP | The root component that owns the primary structure and state. |
| InputOTPGroup | Groups related items into one logical set. |
| InputOTPSlot | A composable part of the component anatomy. |
| InputOTPSeparator | Visually and semantically separates related groups. |
API Reference
Input OTP exports 4 named entries. Component exports accept the props of their underlying HTML element or Base UI component, plus an optional className, unless the source defines a more focused type.
InputOTPComponentInputOTPGroupComponentInputOTPSlotComponentInputOTPSeparatorComponent
Accessibility
- Provide Input OTP with a visible label or an equivalent programmatic accessible name.
- Expose disabled, required, selected, and invalid states through the component API instead of color alone, and keep keyboard focus visible.
Source
Input OTP uses the standard shadcn API and is distributed through Oros. Installing it adds the component source and required dependencies to your app. The Source tab above shows a complete usage example.
Migrating from COSS? Install input-otp in place of otp-field.