Inputs
PinInput
One-time code and PIN entry. Paste, backspace and arrow keys work across cells, and SMS codes autofill.
<script>
import { PinInput } from "@codeatlasdev/ui";
let code = $state("");
</script>
<PinInput label="Verification code" bind:value={code} oncomplete={(v) => verify(v)} />
One hidden input backs all cells, with autocomplete="one-time-code", so mobile keyboards offer the SMS code. In numeric mode the numeric keypad opens and non-digits are rejected. The error is announced with role="alert".
Default
Six digits by default. oncomplete fires once all cells are filled. A four-digit masked PIN is shown below it.
value: – · completed: –
Code
States
Description, error, disabled and a free-text code.
1
2
3
Check your email.
1
2
3
4
5
6
Invalid or expired code.
1
2
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
length | number | 6 | Number of cells. |
value | string | '' | Bindable value. |
type | 'numeric' | 'text' | 'numeric' | Numeric restricts input to digits and opens the numeric keypad. |
label | string | – | Visible label. |
description | string | – | Hint below the cells. |
error | string | – | Error message (role="alert"). Sets aria-invalid. |
mask | boolean | false | Shows a bullet instead of each character. |
disabled | boolean | false | Disables input. |
class | string | – | Extra classes on the root. |
oncomplete | (value: string) => void | – | Called once all cells are filled. |