Pin Input

Enter and manage secure multi-character codes with the PinInput component.

import { PinInput } from '@cerberus/react'

Usage

The PinInput component lets users enter fixed-length codes (such as verification codes or PINs) one character at a time. It manages focus movement between inputs and aggregates the value for you.

Blur on complete

By default, the last input maintains focus when filled, and we invoke the onValueComplete callback. To blur the last input when the user completes the input, set the prop blurOnComplete to true.

Count

The count prop determines the number of individual input boxes rendered. This is useful for specifying the length of the PIN or code the user needs to enter.

Sizes

The PinInput component supports different sizes to accommodate various design requirements.

Primitives

You can utilize the primitive components or the css prop to customize the PinInput component.

ComponentDescription
PinInputRootRoot context provider for the family.
PinInputLabelAccessible label element.
PinInputControlWraps the individual input boxes.
PinInputInputA single character input field.
PinInputHiddenInputAggregated hidden input used in forms.

API

PinInput

The PinInput component is an abstraction over the primitive parts and exposes all Ark UI Root props. Below is a reference table for convenience (see the Ark UI Pin Input API for authoritative details).

NameDefaultDescription
asChildUse the provided child element as the rendered element.
autoFocusAuto‑focus the first input on mount.
blurOnCompleteBlur the last input when the value becomes complete.
countNumber of inputs to render (improves SSR a11y; will become required in next major).
defaultValueUncontrolled initial value array (e.g. ['1','2','3']).
disabledDisable the entire pin input.
dirltrText direction; affects arrow key navigation.
formId of an external form to associate the hidden input with.
idBase id used to derive ids for parts.
idsObject of element id overrides for composition.
invalidMark the pin input as invalid. Adds data-invalid.
maskMask each input character similar to a password field.
nameName attribute for the hidden input (form submission).
onValueChangeFired whenever any input value changes. Provides { value, valueAsString }.
onValueCompleteFired when all inputs have valid values (typing or paste).
onValueInvalidFired when an invalid value is entered (fails type or pattern).
otpEnables one‑time‑code autocomplete optimizations (autocomplete="one-time-code").
patternRegular expression the characters must satisfy.
placeholder"○"Placeholder character shown in empty inputs.
readOnlyMake inputs read‑only.
requiredMark the inputs as required.
selectOnFocusSelect the existing character when an input gains focus.
translationsLocalized strings for accessibility / messages.
type"numeric"Allowed character set: numeric, alphabetic, or alphanumeric.
valueControlled value array (set length to number of inputs).

The PinInput component also accepts standard DOM props for the root element and mirrors the Ark UI Root behavior.

The PinInput is an abstraction of the underlying Ark UI primitive Root component.

Parts

The PinInputParts API is an object containing the full family of components.

NameDescription
RootThe PinInputRoot component which is the provider for the family.
LabelThe PinInputLabel component.
ControlThe PinInputControl layout wrapper.
InputThe PinInputInput component.
HiddenInputThe PinInputHiddenInput component.