OTP Input

An input for entering one-time passwords or verification codes, with separate character cells.

Install

npx @vultra/cli add otp-input

Usage

<script>
  import { OtpInput } from '@vultra/ui';

  let code = $state('');
</script>

<OtpInput length={6} bind:value={code} />
<p>Code: {code}</p>

Props

PropTypeDefaultDescription
valuestringCurrent code value
lengthnumber6Number of input cells
autoFocusbooleantrueFocus first cell on mount
disabledbooleanfalseDisable all inputs
classstring-Additional CSS classes

Events

EventDetailDescription
completestringFires when all cells are filled
changestringFires on each input change

Notes

  • Auto-advances cursor to next cell on input.
  • Supports paste of a full code string.
  • Backspace moves to the previous cell.