Code input
One box per character for a one-time code, digits or letters, shown or hidden: an autofill taken by a tap rises in as a wave, a wrong code is shaken out of its boxes, and a countdown runs to “send again”.
Install
npx airflib@latest add code-input
Usage
import { CodeInput } from "@/components/airflib/components/code-input";
<CodeInput
tone="light"
length={4}
letters={false}
masked={false}
radius={19}
elasticity={50}
resend={true}
/>
API
Its main settings, read from the code: each prop's type and default. The prompt lists every prop.
| Name | Type | Default | Description |
|---|---|---|---|
tone | "light" | "dark" | "light" | Light or dark paint. It does not follow the page theme. |
length | 4 | 5 | 6 | 8 | 6 | How many characters the code has, one box each: 4, 5, 6 and 8 are usual. |
letters | boolean | false | Letters as well as digits (a voucher, a backup code): typed in either case and shown as capitals, with the full keyboard. Off, numbers only (an SMS code), with the number pad. |
masked | boolean | false | Hides the code as a PIN does: a key typed shows a moment, a whole code arriving none, then each melts into a dot. |
radius | number | 12px | Corner radius of each box, in pixels. From 0 to 24px. |
elasticity | number | 50% | How springy the boxes are as they run together into one and part again, in percent: 0 all but firm, 100 a jelly. From 0 to 100%. |
resend | boolean | true | Shows the "send again" countdown and button under the boxes. |
Sound
The sounds in the catalog are the site's. The block comes silent, with a place for your own.