PinInput

Data input

A code typed into separate boxes, as one input underneath: <PinInput.Root> (maxlength, bind:value, pattern, onComplete) draws its boxes in one row. To group them, its children snippet gets the cells, each drawn as a PinInput.Cell; PinInput.Group joins cells into one row and PinInput.Separator puts a dash between groups. Typing moves on, Backspace moves back, pasting fills all boxes, and password managers and one-time-code autofill work. Inside a Field the input is labelled, described and marked invalid by the Field.

import { PinInput } from '@limerdev/zest';
PinInput for AI tools (llms.txt)
Use for
A verification or one-time code of a fixed length.
Don't
Passwords or text of no fixed length: use Input.

Examples

Basic

Six boxes. Pasting a code fills them all.

Groups

The children snippet gets the cells, to split them into groups with a separator.

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

PinInput.Root

Prop Type Default Description
disabled boolean – Whether the input is disabled
inputId string – Optionally provide an ID to apply to the hidden input element.
inputRef HTMLInputElement | null – The underlying hidden <input> element. Bind to call focus(), read selection, etc.
maxlength required number – The max length of the input.
onComplete ((...args: any[]) => void) – A callback function that is called when the input is completely filled.
onValueChange OnChangeFn<string> – A callback function that is called when the value of the input changes.
pasteTransformer ((text: string) => string) – A callback function that is called when the user pastes text into the input. It receives the pasted text as an argument, and should return the sanitized text. Use this function to clean up the pasted text, like removing hyphens or other characters that should not make it into the input.
pushPasswordManagerStrategy "none" | "increase-width" – How to handle the input when a password manager is detected.
textalign "right" | "left" | "center" "left" Customize the alignment of the text within in the input.
value bindable string '' The value of the input.

PinInput.Cell

Prop Type Default Description
cell required PinInputCell – This specific cell, which is provided by the cells snippet prop from the PinInput.Root component.

PinInput.Group

No props of its own beyond the common ones.

PinInput.Separator

No props of its own beyond the common ones.