PIN Input
Allows users to input a sequence of one-character alphanumeric inputs.
Preview
Installation
npx sigma-ui@latest add pin-inputUsage
<script setup lang="ts">
import { ref } from 'vue';
import {
PinInput,
PinInputGroup,
PinInputInput,
} from '@/components/ui/pin-input';
const value = ref<string[]>([]);
</script>
<template>
<PinInput
v-model="value"
@complete="(value) => console.log(value.join(''))"
>
<PinInputGroup>
<PinInputInput
v-for="(id, index) in 5"
:key="id"
:index="index"
/>
</PinInputGroup>
</PinInput>
</template>v-modelis astring[]with one entry per input. Thecompleteevent fires when every input is filled.- Set
type="number"to accept digits only, andotpto enable one-time code autocomplete.
Examples
Controlled
Disabled
Separator
Form
API Reference
PinInput
Props
| Prop | Type | Default |
|---|---|---|
modelValueThe controlled checked state of the pin input. Can be binded as | PinInputValue<Type> | null | [] |
defaultValueThe default value of the pin inputs when it is initially rendered. Use when you do not need to control its checked state. | PinInputValue<Type> | - |
placeholderThe placeholder character to use for empty pin-inputs. | string | - |
maskWhen | boolean | - |
otpWhen | boolean | - |
typeInput type for the inputs. | Type | - |
dirThe reading direction of the combobox when applicable. <br> If omitted, inherits globally from | Direction | - |
disabledWhen | boolean | - |
idId of the element | string | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
nameThe name of the field. Submitted with its owning form as part of a name/value pair. | string | - |
requiredWhen | boolean | - |
Events
| Event | Payload |
|---|---|
update:modelValue | [value: PinInputValue<Type>] |
complete | [value: PinInputValue<Type>] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
PinInputGroup
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
PinInputSeparator
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
PinInputInput
Props
| Prop | Type | Default |
|---|---|---|
indexrequiredPosition of the value this input binds to. | number | - |
disabledWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Accessibility
Renders a group of native text inputs. Reka UI moves focus between them as you type, delete, or paste.
| Key | Description |
|---|---|
| ArrowLeft | Moves focus to the previous input. |
| ArrowRight | Moves focus to the next input. |
| Home | Moves focus to the first input. |
| End | Moves focus to the last input. |
| Backspace | Deletes the value of the current input. If it is empty, moves to the previous input and deletes its value. |
| Delete | Deletes the value of the current input. |
| Ctrl + V | Pastes the clipboard into the inputs, starting from the first input when it fills all of them, or from the current input otherwise. |