PXD

Pin Input

Used to capture a pin code or otp from the user

Default

<script setup>
import { ref } from 'vue'

const code = ref('1234')
</script>

<template>
  <PPinInput v-model="code" />
</template>

Disabled

<script setup>
import { ref } from 'vue'

const code = ref('12')
</script>

<template>
  <PPinInput v-model="code" disabled />
</template>

Placeholder

<template>
  <PPinInput placeholder="🥳" />
</template>

Types

Set the type attribute to limit what can be entered. (Default: numeric)

<template>
  <PStack direction="vertical">
    <PPinInput label="numeric" type="numeric" />
    <PPinInput label="alphabetic" type="alphabetic" />
    <PPinInput label="alphanumeric" type="alphanumeric" />
    <PPinInput label="numeric-password" type="numeric-password" />
    <PPinInput label="alphabetic-password" type="alphabetic-password" />
    <PPinInput label="alphanumeric-password" type="alphanumeric-password" />
  </PStack>
</template>

Length

<template>
  <PPinInput :length="6" />
</template>

Error

<template>
  <PPinInput error="Invalid pin code" />
</template>

Props

NameTypeDefaultDescription
size'xs' | 'sm' | 'md' | 'lg'-Box side length in px: 24, 30, 36 or 44, falling back to the config size
errorboolean | string-Any truthy value turns on the error border and focus ring
lengthnumber4Number of single-character boxes to render
readonlyboolean-Allow focus and selection but block typing
disabledboolean-Disable all boxes and ignore typed or pasted input
model-valuestring``Current pin code, one character per box
placeholderstringâ—‹Character shown in each empty box
type'numeric' | 'alphabetic' | 'alphanumeric' | 'numeric-password' | 'alphabetic-password' | 'alphanumeric-password'numericRestrict input to the given character set, the -password variants also mask it

Events

NameTypeDescription
change(value: string) => voidEmitted when a box is filled or cleared, when the whole code is pasted, or when an IME composition ends.
update:modelValue(value: string) => voidEmitted alongside change on every value update.

Methods

NameTypeDescription
focus() => voidSelect the first box so the next keystroke starts from the beginning.
blur() => voidBlur every box at once.

Source

Source