Skip to content

Pin / OTP Input

Enter a verification code or PIN across separate cells.

Demos

Size
Variant

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy PinInput.vue and index.ts into app/components/ui/pin-input/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm
variantoutline, soft, bareoutline

Props

PropTypeDefaultDescription
lengthnumber4Number of cells; clamped to at least one.
type"text" | "number""text"Character mode and input metadata.
maskbooleanfalseRenders password cells.
otpbooleanfalseEnables one-time-code autocomplete on the first cell.
placeholderstring""Placeholder applied to every cell.
allowedCharsRegExp | (character) => booleannon-whitespaceAdditional character filter.
selectOnFocusbooleantrueSelects a cell value when focused.
autoFocusbooleanfalseFocuses the first cell after mount.
idstringfield/generated idFirst cell id. Later cells receive numbered suffixes.
namestringfield nameNative form field name.
requiredbooleanfalseRequires all cells to be filled.
disabledbooleanfalseDisables every cell and form submission.
readOnlybooleanfalsePrevents value changes while retaining focus.
invalidbooleanfalseForces invalid styling and ARIA state.
dir"ltr" | "rtl""ltr"Cell direction and Arrow-key behavior.
ariaLabelstring"Pin input"Group label and per-cell label prefix.
ariaLabelledbystring-Accessible label element id.
ariaDescribedbystringfield IDsAccessible description/error ids.
uiPinInputUi-Classes for structural parts.

Slots

SlotPropsDescription
cellindex, value, isFilled, isActive, inputPropsCustom cell. Bind inputProps to an input.

Events

EventPayloadDescription
value-change(value, details)Fires before the canonical value updates. Cancelable.
complete(value, details)Fires after every cell becomes filled.

Keyboard

KeyBehavior
text inputAccepts valid characters and advances focus. Multiple characters distribute forward.
pasteDistributes valid characters from the current cell.
ArrowLeft / ArrowRightMove between cells, respecting dir.
Home / EndFocus first/last cell.
BackspaceClears current cell, or previous cell when current is empty.
DeleteClears current cell.