components/bits/CodeInput#
CodeInput()#
One box per digit, for short numeric codes (TOTP).
Boxes are more legible than a dense field and make the expected length obvious, but only if they behave like a single field: paste fills every box from wherever the caret is, backspace walks backwards through them, and the arrow/Home/End keys move between them. The value is owned by the parent, so clearing it from outside just empties the boxes.
Parameters#
| Parameter | Type |
|---|---|
props |
CodeInputProps |
Returns#
Element
CodeInputProps#
Properties#
autoFocus?#
disabled?#
error?#
groupSize?#
Where to put the visual gap, e.g. 3 renders 3-3 for a six-digit code.
label?#
length?#
onChange#
Parameters#
| Parameter | Type |
|---|---|
value |
string |
Returns#
void
onComplete?#
Fired once when the last empty slot is filled, with the complete code.
Parameters#
| Parameter | Type |
|---|---|
value |
string |
Returns#
void
value#
The code so far. Always digits only, never longer than length.