Search documentation

Search the documentation and open a page.

Displays a one-time password input with individual character slots.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/input-otp

Composition

InputOTP ├── InputOTPLabel (optional) └── InputOTPGroup ├── InputOTPSlot └── InputOTPSeparator (optional)

Examples

Cells

Loading...

Default

Loading...

Digits Only

Loading...

Separator

Loading...

API Reference

InputOTP

PropTypeDefaultDescription
idstring | undefined—Unique identifier used to connect the component parts.
namestring | undefined—Name used when submitting the value with a form.
formstring | undefined—Associates the control with a form by ID.
patternstring | undefined—Configures pattern.
idsElementIds | undefined—Overrides generated identifiers for individual parts.
disabledboolean | undefinedfalseDisables interaction with the component.
placeholderstring | undefined—Configures placeholder.
autoFocusboolean | undefined—Configures auto focus.
invalidboolean | undefined—Marks the associated form control as invalid.
requiredboolean | undefinedfalseMarks the associated form control as required.
readOnlyboolean | undefinedfalsePrevents changes while preserving focus and navigation.
otpboolean | undefined—Configures otp.
valuestring[] | undefined—Current value when the component is controlled.
defaultValuestring[] | undefined—Initial value when the component is uncontrolled.
type"alphanumeric" | "numeric" | "alphabetic" | undefined—Configures type.
onValueComplete((details: ValueChangeDetails) => void) | undefined—Runs when value complete changes.
onValueChange((details: ValueChangeDetails) => void) | undefined—Runs when value changes.
onValueInvalid((details: ValueInvalidDetails) => void) | undefined—Runs when value invalid changes.
maskboolean | undefined—Configures mask.
autoSubmitboolean | undefined—Configures auto submit.
blurOnCompleteboolean | undefined—Configures blur on complete.
selectOnFocusboolean | undefined—Configures select on focus.
sanitizeValue((value: string) => string) | undefined—Configures sanitize value.
translationsIntlTranslations | undefined—Configures translations.
countnumber | undefined—Configures count.

Context, Hooks, and Types

ExportAPI
InputOTPContextRender-prop component that exposes component state and actions.
InputOTPRootProviderProvides an externally created API to the component tree.
usePinInputCreates or accesses the component API.
usePinInputContextReturns the nearest component API.
PinInputValueChangeDetailsType for the details object passed to the matching change callback.