Skip to content
Forms

PinInput

One box per character, for verification codes.

import
import { PinInput } from '@joshicodes/cock';

Code

Paste a whole code into any box; it fills from there.

Keyboard

Backspace
Clears the current box, or steps back and clears the previous one
← →
Moves between boxes
Paste
Fills from the box you pasted into, ignoring anything that does not fit

Behaviour

  • The first box carries `autocomplete="one-time-code"`, so the phone offers the code from the SMS.

API

Read out of the component sources at build time, so it matches the version you installed. Every component also takes class, merged through tailwind-merge so your utility wins.

Props of PinInput

PropTypeDefault
value bindable
string''
length
number6
type
'numeric' | 'alphanumeric''numeric'
mask

Hide the characters, like a password field.

booleanfalse
group

Put a small gap after this many boxes, e.g. 3 for "123 456".

number—
disabled
booleanfalse
invalid
booleanfalse
label

Accessible name for the whole group.

string'Verification code'
class
string—

Events of PinInput

EventTypeDefault
oncomplete
(value: string) => void—

See also

cock. Yes, it stands for core component kit. We checked twice.