PinInput
A multi-cell controlled code input with paste, OTP, and keyboard navigation support.
PinInputView sourceExample
The preview is interactive. The code below it is the docs demo source; demo-only layout classes can be omitted in application code.
Enter the six-digit code.
import { Cell } from "retend";
import { Field, PinInput } from "innate-ui";
import classes from "../docs.module.css";
export function PinInputDemo() {
const code = Cell.source("");
return (
<Field id="pin-input-demo" class={[classes.selectExample, classes.pinInputDemo]}>
<Field.Label>Verification code</Field.Label>
<PinInput value={code} length={6} otp onChange={(value) => code.set(value)} />
<Field.Description>Enter the six-digit code.</Field.Description>
</Field>
);
}API reference
This table is generated from Innate UI's exported TypeScript declarations and JSDoc. Native element attributes inherited by a prop type are not repeated here.
PinInputProps
| Prop | Type | Default |
|---|---|---|
valuerequiredCurrent PIN/code as one contiguous string. | JSX.ValueOrCell<string> | — |
lengthNumber of input cells. This is structural and must be a positive integer. | number | 4 |
idStable control id when the component is not inside `Field`. | string | — |
typeAccepted character class. | PinInputType | "numeric" |
patternAdditional regular expression applied to each entered character. | string | — |
placeholderPlaceholder shown in empty cells. | JSX.ValueOrCell<string> | — |
maskWhether entered characters are visually masked. | JSX.ValueOrCell<boolean> | false |
otpEnables one-time-code autofill semantics. | JSX.ValueOrCell<boolean> | false |
disabledWhether all cells are disabled. | JSX.ValueOrCell<boolean> | false |
readOnlyWhether all cells are read-only. | JSX.ValueOrCell<boolean> | false |
requiredWhether every cell is required for native form validation. | JSX.ValueOrCell<boolean> | false |
invalidWhether the control is in an invalid state. | JSX.ValueOrCell<boolean> | false |
ariaDescribedByIds of elements that describe the control. | JSX.ValueOrCell<string | undefined> | — |
ariaLabelledByIds of elements that label the grouped control. | JSX.ValueOrCell<string | undefined> | — |
nameName used for form submission of the complete code. | string | — |
formId of a form to associate with the cells and submitted value. | string | — |
autoFocusAutofocuses the current insertion cell when mounted. | boolean | false |
blurOnCompleteBlurs the last focused cell when the code becomes complete. | boolean | false |
sanitizeValueOptional paste/autofill sanitizer, e.g. removing spaces or dashes. | (value: string) => string | — |
onChangeCalled with the next complete string whenever the user edits the code. | (value: string) => void | — |
onCompleteCalled after a user edit produces a value with `length` characters. | (value: string) => void | — |