Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
InputOTP ├── InputOTPLabel (optional) └── InputOTPGroup ├── InputOTPSlot └── InputOTPSeparator (optional)
Examples
Cells
Loading...
Default
Loading...
Digits Only
Loading...
Separator
Loading...
API Reference
InputOTP
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
name | string | undefined | — | Name used when submitting the value with a form. |
form | string | undefined | — | Associates the control with a form by ID. |
pattern | string | undefined | — | Configures pattern. |
ids | ElementIds | undefined | — | Overrides generated identifiers for individual parts. |
disabled | boolean | undefined | false | Disables interaction with the component. |
placeholder | string | undefined | — | Configures placeholder. |
autoFocus | boolean | undefined | — | Configures auto focus. |
invalid | boolean | undefined | — | Marks the associated form control as invalid. |
required | boolean | undefined | false | Marks the associated form control as required. |
readOnly | boolean | undefined | false | Prevents changes while preserving focus and navigation. |
otp | boolean | undefined | — | Configures otp. |
value | string[] | undefined | — | Current value when the component is controlled. |
defaultValue | string[] | 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. |
mask | boolean | undefined | — | Configures mask. |
autoSubmit | boolean | undefined | — | Configures auto submit. |
blurOnComplete | boolean | undefined | — | Configures blur on complete. |
selectOnFocus | boolean | undefined | — | Configures select on focus. |
sanitizeValue | ((value: string) => string) | undefined | — | Configures sanitize value. |
translations | IntlTranslations | undefined | — | Configures translations. |
count | number | undefined | — | Configures count. |
Context, Hooks, and Types
| Export | API |
|---|---|
InputOTPContext | Render-prop component that exposes component state and actions. |
InputOTPRootProvider | Provides an externally created API to the component tree. |
usePinInput | Creates or accesses the component API. |
usePinInputContext | Returns the nearest component API. |
PinInputValueChangeDetails | Type for the details object passed to the matching change callback. |
Angular
React
Solid
Svelte
Vue