Homelogologo
Sponsor

PinInput

For optimized user experience of entering a PIN or OTP.

Usage

A compound component that provides an optimized experience for entering multi-digit codes like PINs or One-Time Passwords (OTPs).

import { PinInput, Input } from "@elemnts-ui/react"; <PinInput.Root onValueComplete={(e) => console.log(e.value)}> <PinInput.Control> {Array.from({ length: 4 }).map((_, idx) => ( <PinInput.Input asChild index={idx} key={idx}> <Input variant="secondary" boxSize="2.4rem" fontSize="20" /> </PinInput.Input> ))} </PinInput.Control> </PinInput.Root>;

Masking

Use the mask prop to obscure the input values, similar to a password input.

OTP Mode

Use the otp prop to signal to mobile devices that the input is a one-time password, enabling auto-fill features.

With Field

The PinInput can be used within a Field component to provide a label, helper text, and validation states.

API Reference

PinInput

The root container for the pin input.

PropTypeDefault
asChildbooleanfalse
autoFocusboolean-
autoSubmitboolean-
blurOnCompleteboolean-
countnumber-
defaultValuestring[]-
disabledboolean-
formstring-
idstring-
idsPartial<{ root: string; hiddenInput: string; label: string; control: string; input: (id: string) => string }>-
invalidboolean-
maskboolean-
namestring-
onValueChange(details: ValueChangeDetails) => void-
onValueComplete(details: ValueChangeDetails) => void-
onValueInvalid(details: ValueInvalidDetails) => void-
otpboolean-
patternstring-
placeholderstring"â—‹"
readOnlyboolean-
requiredboolean-
sanitizeValue(value: string) => string-
selectOnFocusboolean-
translationsIntlTranslations-
type"numeric" | "alphanumeric" | "alphabetic""numeric"
valuestring[]-

PinInputRootProvider

Provides the pin input state created with usePinInput to its child components.

PropTypeDefault
valueUsePinInputReturnrequired
asChildbooleanfalse

PinInputLabel

The accessible label for the pin input.

PropTypeDefault
asChildbooleanfalse

PinInputControl

The container for the individual input fields.

PropTypeDefault
asChildbooleanfalse

PinInputInput

An individual input field for a PIN digit.

PropTypeDefault
indexnumberrequired
asChildbooleanfalse

PinInputHiddenInput

A hidden native input used for form submission.

PropTypeDefault
asChildbooleanfalse

PinInputContext

Provides the pin input API to a render function.