Forms
PinInput
A multi-cell input for PIN codes, OTP verification, and security codes. Supports masking, numeric mode, auto-complete, and onComplete callback.
Playground
Experiment with different props in real-time.
○
○
○
○
○
Basic Usage
○
○
○
○
○
<script lang="ts">
import { PinInput } from 'sv5ui';
let value = $state('');
</script>
<PinInput bind:value />Custom Length
Set the number of cells.
-
-
-
-
○
○
○
○
○
○
<PinInput length={4} placeholder="-" />
<PinInput length={6} placeholder="○" />Numeric Only
Restrict to digits with type="number".
0
0
0
0
0
<!-- Number only -->
<PinInput type="number" placeholder="0" />Masked
Hide input with mask.
○
○
○
○
○
<!-- Masked input (shows ● instead of characters) -->
<PinInput mask />OTP Mode
Enable otp for autocomplete="one-time-code".
○
○
○
○
○
○
<!-- OTP mode (sets autocomplete="one-time-code") -->
<PinInput otp type="number" length={6} />Variants
5 visual styles.
outline
○
○
○
○
soft
○
○
○
○
subtle
○
○
○
○
ghost
○
○
○
○
<PinInput variant="outline" />
<PinInput variant="soft" />
<PinInput variant="subtle" />
<PinInput variant="ghost" />Sizes
xs
○
○
○
○
sm
○
○
○
○
md
○
○
○
○
lg
○
○
○
○
xl
○
○
○
○
<PinInput size="xs" length={4} />
<PinInput size="sm" length={4} />
<PinInput size="md" length={4} />
<PinInput size="lg" length={4} />
<PinInput size="xl" length={4} />Colors
Visible with highlight active.
primary
1
2
3
4
5
success
1
2
3
4
5
error
1
2
3
4
5
<PinInput color="primary" highlight value="12345" />
<PinInput color="success" highlight value="12345" />
<PinInput color="error" highlight value="12345" />Disabled
1
2
3
○
○
<PinInput disabled value="123" />On Complete
Callback when all cells are filled.
○
○
○
○
<script lang="ts">
import { PinInput } from 'sv5ui';
let completed = $state('');
function handleComplete(value: string) {
completed = value;
}
</script>
<PinInput onComplete={handleComplete} length={4} type="number" />
{#if completed}
<p>Completed: {completed}</p>
{/if}Controlled
Two-way binding.
○
○
○
○
○
Value: (empty)
<script lang="ts">
import { PinInput } from 'sv5ui';
let value = $state('');
</script>
<PinInput bind:value />
<p>Value: {value || '(empty)'}</p>UI Slots
Use the ui prop to override classes.
| Slot | Description |
|---|---|
root | Root container |
base | Individual cell elements |
Props
| Prop | Type | Default |
|---|---|---|
value | string | '' |
length | number | 5 |
type | 'text' | 'number' | 'text' |
mask | boolean | false |
otp | boolean | false |
placeholder | string | '○' |
variant | 'outline' | 'soft' | 'subtle' | 'ghost' | 'none' | 'outline' |
color | ColorType | 'primary' |
size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
highlight | boolean | false |
autofocus | boolean | false |
autofocusDelay | number | 0 |
disabled | boolean | false |
required | boolean | false |
onValueChange | (value) => void | - |
onComplete | (value) => void | - |
name | string | - |
ref | HTMLElement | null | null |
class | string | - |
ui | Record<Slot, Class> | - |