Pin Input

A pin input component for entering verification codes, PINs, or OTP values with individual character inputs.

Anatomy

<script>
  import { PinInput } from "@saas-ui/svelte/components/pin-input";
</script>

<PinInput count={4} otp />

Examples

Alphanumeric Accessibility

Pin input with different input types: numeric, alphabetic, or alphanumeric.

Attached Accessibility

Pin input with visually attached inputs using the attached prop.

Basic Accessibility

Basic pin input with default styling and four character inputs.

Colours Accessibility

Pin input with different colour schemes using the colour prop.

Controlled Accessibility

Controlled pin input with external state management.

Count Accessibility

Pin input with different counts of character inputs.

Disabled Accessibility

Disabled pin input that prevents user interaction.

Invalid Accessibility

Use the invalid prop to display validation error styling.

Mask Accessibility

Pin input with masked values for sensitive codes like PINs.

One Time Code Accessibility

Pin input in OTP mode for one-time codes with autocomplete support.

Placeholder Accessibility

Pin input with custom placeholder characters.

Sizes Accessibility

Pin input in different sizes. Available sizes: xs, sm, md, lg.

Variants Accessibility

Pin input with different variants. Available variants: outline, subtle, flushed.

With Field Accessibility

Pin input with Field wrapper for label and helper text support.

Props

PinInput

A composed pin input component that renders individual character inputs for entering codes.

Prop Type Default Description
variant "outline" | "subtle" | "flushed" "outline" The visual style of the pin input.
size "xs" | "sm" | "md" | "lg" "md" The size of the pin input.
colour ColourName "gray" The colour theme of the pin input.
invalid boolean false Whether the pin input is in an invalid state.
disabled boolean false Whether the pin input is disabled.
placeholder string "○" The placeholder text for each input.
value string[] - The current value of the pin input (bindable).
defaultValue string[] - The default value of the pin input.
onValueChange (details: { value: string[]; valueAsString: string }) => void - Callback when the value changes.
onValueComplete (details: { value: string[]; valueAsString: string }) => void - Callback when all inputs have valid values.
onValueInvalid (details: { value: string; index: number }) => void - Callback when an invalid value is entered.
count number 4 The number of pin inputs to render.
type "numeric" | "alphabetic" | "alphanumeric" "numeric" The type of value the pin input should allow.
otp boolean false Whether the pin input is in one-time code (OTP) mode.
mask boolean false Whether to mask the input value (like password).
attached boolean false Whether the inputs are visually attached to each other.
autoFocus boolean false Whether to auto-focus the first input.
blurOnComplete boolean false Whether to blur on complete.
selectOnFocus boolean true Whether to select input value on focus.
name string - The name attribute for form submission.
required boolean false Whether the pin input is required.
readOnly boolean false Whether the pin input is read-only.
class string - Additional CSS classes to apply.
style string - Inline styles.
id string - The id of the pin input.
aria-label string - Accessible label for the pin input group.