navius

One-Time Password Field

A group of single-character inputs for entering a one-time code, with auto-advance, paste, and SMS autofill.

Features

  • Auto-advances on type and retreats on backspace; full arrow / Home / End navigation.
  • Pasting (or SMS autofill) fills the whole field at once.
  • Numeric / alpha / alphanumeric validation, optional AutoSubmit, and a hidden input for form posts.
  • Controlled (@bind-Value) or uncontrolled (DefaultValue).

Installation

Anatomy

API Reference

Groups the cells (role="group") and owns the aggregate value. Renders a div.

Prop Type Default
Length int 6
Value string? -
ValueChanged EventCallback<string> -
DefaultValue string? -
Disabled bool false
ReadOnly bool false
InputMode string "numeric"
ValidationType string "numeric"
SanitizeValue Func<string,string>? -
Type string "text"
Orientation string "vertical"
Placeholder string? -
AutoFocus bool false
AutoSubmit bool false
OnComplete EventCallback<string> -
OnAutoSubmit EventCallback<string> -
Name string? -
Form string? -
Data attribute Values
[data-orientation] "horizontal" | "vertical"
[data-disabled] Present when disabled

A single character cell. Renders an input.

Prop Type Default
Index int -
Data attribute Values
[data-filled] Present when the cell has a character
[data-index] The cell's zero-based index
[data-orientation] "horizontal" | "vertical"
[data-disabled] Present when disabled

A visually-hidden input carrying the aggregate value for form submission.

Prop Type Default
Name string? -
Form string? -

Accessibility

The cells are grouped with role="group"; each cell is named "Character N of M". Cells use autocomplete="one-time-code" for SMS autofill.

Key Description
0-9 / a-z Writes the focused cell and advances to the next.
Backspace Clears the focused character (or the previous when empty) and retreats.
Ctrl/Cmd + Backspace Clears the entire field and focuses the first cell.
Delete Clears the focused character and shifts the rest back.
ArrowLeft / ArrowRight Moves between cells (horizontal orientation).
ArrowUp / ArrowDown Moves between cells (vertical orientation).
Home / End Jumps to the first / last cell.
Enter Submits the owning form.