PinInput
Segmented input for PIN/OTP codes with single hidden input architecture
Start Here
Start from the smallest working snippet, then move to interactive examples and the full API contract below.
Styled quick start
Copy this entrypoint first. It includes the imports required to get the component on screen.
<script lang="ts">
import '@dryui/ui/themes/default.css';
import '@dryui/ui/themes/dark.css';
import { PinInput } from '@dryui/ui';
</script>
<PinInput.Root bind:value={pin} length={6} oncomplete={handleVerify}>
{#snippet children({ cells })}
<PinInput.Group>
{#each cells.slice(0, 3) as cell}
<PinInput.Cell {cell} />
{/each}
</PinInput.Group>
<PinInput.Separator />
<PinInput.Group>
{#each cells.slice(3) as cell}
<PinInput.Cell {cell} />
{/each}
</PinInput.Group>
{/snippet}
</PinInput.Root>Import options
Root package
import { PinInput } from '@dryui/ui'Per-component subpath
import { PinInput } from '@dryui/ui/pin-input'Customize
Use the interactive examples to see common variants, states, and composition patterns before building your own.
Simple (4-Digit)
<PinInput.Root length={4} />Grouped with Separator
<PinInput.Root length={6}>
{#snippet children({ cells })}
<PinInput.Group>
{#each cells.slice(0, 3) as cell}
<PinInput.Cell {cell} />
{/each}
</PinInput.Group>
<PinInput.Separator />
<PinInput.Group>
{#each cells.slice(3) as cell}
<PinInput.Cell {cell} />
{/each}
</PinInput.Group>
{/snippet}
</PinInput.Root>Masked Input
<PinInput.Root length={4} mask />Alphanumeric
<PinInput.Root length={6} type="alphanumeric" placeholder="-" />Sizes
<PinInput.Root length={4} size="sm" />
<PinInput.Root length={4} size="md" />
<PinInput.Root length={4} size="lg" />Flushed Variant
<PinInput.Root length={4} variant="flushed" />Disabled
<PinInput.Root length={4} disabled />Structure
Compound components always start with PinInput.Root. Use this structure block to understand required wrappers before you wire state or styling.
PinInput.Root
PinInput.Group
PinInput.Cell
PinInput.Separator Compose
The full API contract lives here: props, CSS variables, and the public data attributes you can target when styling.
Compound component. Start with PinInput.Root, then add only the parts you need.
PinInput.Root
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
value | string | '' | — | ✓ |
length | number | 4 | — | — |
mask | boolean | false | — | — |
type | numericalphanumeric | 'numeric' | — | — |
pattern | RegExp | — | — | — |
placeholder | string | '○' | — | — |
disabled | boolean | false | — | — |
oncomplete | (value: string) => void | — | — | — |
pasteTransformer | (text: string) => string | — | — | — |
blurOnComplete | boolean | false | — | — |
name | string | — | — | — |
size | smmdlg | 'md' | — | — |
variant | outlineflushed | 'outline' | — | — |
children | Snippet<[{ cells: PinInputCellType[] }]> | — | — | — |
Forwards <div> attributes via rest props. Common examples: id, style, role. Omitted: children.
PinInput.Group
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
children | Snippet | — | ✓ | — |
Forwards <div> attributes via rest props. Common examples: id, style, role.
PinInput.Cell
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
cell | PinInputCellType | — | ✓ | — |
children | Snippet<[{ char: string | null; isActive: boolean; hasFakeCaret: boolean }]> | — | — | — |
Forwards <div> attributes via rest props. Common examples: id, style, role. Omitted: children.
PinInput.Separator
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
children | Snippet | — | — | — |
Forwards <div> attributes via rest props. Common examples: id, style, role.