One-Time Password Field API
View componentThe full prop reference for the One-Time Password Field component. A segmented input for OTP / PIN codes.
Import
import { One-TimePasswordField } from '@structyl/styled';Props
Root
The root container for the one-time-password field. Manages state and context for all inputs.
| Prop | Type | Default |
|---|---|---|
| length# | numberNumber of input fields to display | 6 |
| value# | stringControlled value of the OTP field | — |
| defaultValue# | stringInitial uncontrolled value | '' |
| onValueChange# | (value: string) => voidCallback fired when the OTP value changes | — |
| type# | 'numeric' | 'alphanumeric'Input type constraint | 'numeric' |
| mask# | booleanMask input as password field when true | — |
| autoSubmit# | booleanTrigger onComplete when all fields are filled | true |
| disabled# | booleanDisable all input fields | — |
| onComplete# | (value: string) => voidCallback fired when all OTP fields are completed and autoSubmit is true | — |
| asChild# | booleanRender as child element instead of div | — |
| className# | stringCSS class name for styling | — |
| ref# | React.Ref<HTMLDivElement>Ref forwarded to root div element | — |
Input
Individual OTP input field. Must be used inside Root. Requires an index prop.
| Prop | Type | Default |
|---|---|---|
| index# | numberPosition of this input in the OTP field (0-based) | — |
| className# | stringCSS class name for styling | — |
| disabled# | booleanDisable this specific input field | — |
| onChange# | (event: React.ChangeEvent<HTMLInputElement>) => voidNative change event handler (composed with internal handler) | — |
| onKeyDown# | (event: React.KeyboardEvent<HTMLInputElement>) => voidNative keydown event handler (composed with internal arrow/backspace handler) | — |
| onFocus# | (event: React.FocusEvent<HTMLInputElement>) => voidNative focus event handler (composed with internal select handler) | — |
| ref# | React.Ref<HTMLInputElement>Ref forwarded to input element | — |
Source code
If you didn't find what you need here, read the component implementation .