UseOtpInputResult
Properties
Section titled “Properties”baseId
Section titled “baseId”baseId: string;Base id; slots derive ${baseId}-slot-0, …
clear: () => void;Reset to empty and refocus.
Returns
Section titled “Returns”void
focus: () => void;Focus the underlying input.
Returns
Section titled “Returns”void
getContainerProps
Section titled “getContainerProps”getContainerProps: (props?) => HTMLAttributes<HTMLDivElement>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
props? | HTMLAttributes<HTMLDivElement> |
Returns
Section titled “Returns”HTMLAttributes<HTMLDivElement>
getInputProps
Section titled “getInputProps”getInputProps: (props?) => InputHTMLAttributes<HTMLInputElement> & object;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
props? | InputHTMLAttributes<HTMLInputElement> |
Returns
Section titled “Returns”InputHTMLAttributes<HTMLInputElement> & object
getSlotProps
Section titled “getSlotProps”getSlotProps: (index, props?) => HTMLAttributes<HTMLDivElement>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
index | number |
props? | HTMLAttributes<HTMLDivElement> |
Returns
Section titled “Returns”HTMLAttributes<HTMLDivElement>
inputRef
Section titled “inputRef”inputRef: object;Structural rather than RefObject: in @types/react 18 RefObject.current
is readonly, in 19 it is mutable. Declaring the shape keeps this assignable
under both, which matters because react >= 18 is the peer.
current
Section titled “current”current: HTMLInputElement | null;isComplete
Section titled “isComplete”isComplete: boolean;value.length === length.
isFocused
Section titled “isFocused”isFocused: boolean;The underlying input holds focus.
length
Section titled “length”length: number;Slot count after normalization.
setValue
Section titled “setValue”setValue: (value) => void;Commit a value programmatically (sanitized like any other input). Used by WebOTP autofill.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value | string |
Returns
Section titled “Returns”void
slots: OtpSlotState[];Per-slot state, in order.
value: string;The current sanitized value.