Skip to content

Pin Input

Enter a short code across coordinated single-character fields.

Usage

Verification code

Enter a short numeric verification code one segment at a time.

Enter a short numeric verification code one segment at a time.

Custom length

Set the number of input cells to match the code format required by the service.

Set the number of input cells to match the code format required by the service.

Masked input

Hide entered characters when the code should not remain visible on screen.

Hide entered characters when the code should not remain visible on screen.

Cell placeholders

Pass a placeholder to each input cell without storing it as part of the value.

Pass a placeholder to each input cell without storing it as part of the value.

OTP autocomplete

Opt in to one-time-code autocomplete for a value that is intentionally an OTP.

Opt in to one-time-code autocomplete for a value that is intentionally an OTP.

Readonly

Remain focusable for inspection while rejecting every mutation request.

Remain focusable for inspection while rejecting every mutation request.

Disabled

Remove the control from keyboard and pointer interaction.

Remove the control from keyboard and pointer interaction.

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

API

Vue package: @sectile/vue/pin-input

Components
  • PinInputRoot
  • PinInputInput

Props

PinInputRootProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

form

ID of the native form associated with the control.

label

Accessible name announced for the control.

length

Number of coordinated character inputs.

mask

Whether entered characters use password-style masking.

modelValue

Current value when state is controlled by the parent.

name

Name used for native form submission.

otp

Whether to opt the first input into one-time-code autocomplete.

policies

Behavior policies that customize validation, movement, or selection.

readonly

Whether the value can be inspected but not changed.

required

Whether the control must contain a valid value before submission.

PinInputInputProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

index

Zero-based position of this part in its parent collection.

Slots

PinInputRootSlotProps

complete

Whether every required character or step is complete.

disabled

Whether interaction is unavailable.

readonly

Whether the value can be inspected but not changed.

value

Current value exposed by this contract.

PinInputInputSlotProps

character

Character displayed by this input.

complete

Whether every required character or step is complete.

disabled

Whether interaction is unavailable.

index

Zero-based position in the parent collection.

readonly

Whether the value can be inspected but not changed.

value

Current value exposed by this contract.

Events

PinInputRoot

complete

Emitted when every required segment is filled.

update:modelValue

Emitted when the component requests a new controlled value.

Other types

PinInputValueChangeHandler

ts
type PinInputValueChangeHandler = (value: string) => void

PinInputCompleteHandler

ts
type PinInputCompleteHandler = (value: string) => void

Parts

Shared scope: [data-scope="pin-input"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
input[data-part="input"]Accepts the editable value or draft.

Keyboard interaction

KeyBehavior
Arrow Left / Arrow RightMove between digit inputs.
Backspace / DeleteClear a digit and preserve the expected cursor movement.
Text inputAccept valid characters and advance when the field is complete.

Accessibility

Each digit input has an independent accessible name and preserves a predictable focus order.

Released under the MIT License.