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

Terminal
npx airflib@latest add code-input

Usage

TSX
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.

NameTypeDefaultDescription
tone"light" | "dark""light"Light or dark paint. It does not follow the page theme.
length4 | 5 | 6 | 86How many characters the code has, one box each: 4, 5, 6 and 8 are usual.
lettersbooleanfalseLetters 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.
maskedbooleanfalseHides the code as a PIN does: a key typed shows a moment, a whole code arriving none, then each melts into a dot.
radiusnumber12pxCorner radius of each box, in pixels. From 0 to 24px.
elasticitynumber50%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%.
resendbooleantrueShows 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.