PIN input
ProOne box per character for verification codes, PINs and vouchers, with paste and one-time-code autofill. Not an M3 component (@windmorph/react-pro).
import { PinInput } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Purpose
A PIN input takes a short code of fixed length, one character per box: email and SMS verification codes, password reset and two-factor codes, PINs, and invite or voucher codes. It is not an M3 component: it comes from @windmorph/react-pro, and each box is drawn with the M3 text field's tokens, so it sits naturally next to a Text field.
One real input sits invisibly over the boxes. Typing, pasting ("123 456" or "Code: 123456" both become 123456), one-time-code autofill on phones and password managers all work as in a normal field. Codes of up to six characters fit a 320px phone in every size.
Behaviour
density(or the theme's, through a provider orThemeScope) takes 4px a step off the boxes' height: 56px at 0 to 44px at -3 at themdsize, as the core's fields.- Box sizes are minimums (at least 1.25em each way), so text at 200% makes the boxes bigger instead of clipping the characters.
- Disabled parts dim with the M3 disabled state opacities. An invalid code shakes the row on the default spatial spring on every swing, and the caret blinks as a step (500ms on, 500ms off).
When not to use
For anything of variable or longer length (passwords, recovery keys, phone numbers), use a Text field.
See also
- Text field: Filled or outlined text input with a floating label, icons, affixes, counter, error icon and a text area.