Dot Code
A plain code field, typed, pasted or filled by the phone's one-time-code autofill, drawn as small dot panels. Each digit scans in from the top as a dot display refreshes; a right code sweeps the dots green, a wrong one flashes red and scatters out to try again.
Needs: None. Canvas 2D; the tick uses Web Audio and only plays after a click.
Customize
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| length | number | 6 | How many digits. |
| onChange | (code: string) => void | – | Called with the code as it changes. |
| onComplete | (code: string) => void | – | Called once every digit is in. |
| verify | (code: string) => boolean | Promise<boolean> | – | Checks a full code: true sweeps it green, false flashes it red and wipes it. |
| tone | string | – | The colour of a lit dot. The text colour when unset. |
| pitch | number | 5 | Size of one dot in CSS px. A box is 7 dots wide, 11 tall. |
| glow | boolean | true | A soft bloom round lit dots. |
| sound | boolean | false | A soft tick as each digit lights. |
| autoFocus | boolean | false | Focus the field on mount. |
| disabled | boolean | false | Locked out. |
| label | string | "Code" | Read out by screen readers. |
| className | string | – | Class on the field. |
| style | CSSProperties | – | Style on the field. |