Input OTP
A segmented one-time-code input — real single-char cells with native caret and mobile keyboard, paste distribution, and full keyboard navigation. Controlled: the parent owns the full value string and updates it from @change, while @complete fires once the code is filled.
Installation
Copy the piece into your app — it compiles with your build and the code is yours:
puzzle add piece input-otp
No dependencies. Requires the pieces.css tokens merged into your app styles (see Introduction).
Usage
import InputOtp from '@/components/ui/InputOtp.pzl';
<InputOtp value={ code } @change={ setCode } />Groups
Alphanumeric
Error
Complete callback
There is no auto-submit — @complete is the parent's hook, firing once the moment the value reaches length. Type six digits below:
Waiting for all six digits…
Keyboard and paste
- Type a character — fills the cell and advances to the next
- Paste a code — distributes left-to-right from the focused cell, landing on the next empty cell
- Backspace — clears the current cell, or on an empty cell moves back and clears the previous one
- Delete — clears the current cell in place
- Left / Right arrows — move between cells
- Home — first cell
- End — first empty cell (the last cell once full)