ValyroUI English version

OTP Input

Ввод одноразового кода. Бесплатно, MIT · Формы и ввод › Числа, коды и маски

Установка

npx valyro-cli@latest add otp-input
npx shadcn@latest add https://valyro.xyz/r/otp-input.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { OTPInput } from 'valyro-ui';

Пропсы

PropTypeDefault
lengthnumber6Number of boxes.
valuestringControlled value; use with onValueChange.
defaultValuestring''Initial value when uncontrolled.
onValueChange(value: string) => voidCalled with the new value when it changes.
onComplete(value: string) => voidCalled once every box is filled.
type'numeric' | 'alphanumeric''numeric'Characters kept from typing and paste: digits only (numeric keypad on phones), or Latin letters and digits.
separatorbooleanfalseDraw a dash between the two halves.
invalidbooleanfalseDanger borders and a shake on every box; sets aria-invalid on the inputs.
disabledbooleanfalseDisables every box; the code is not submitted with the form.
autoFocusbooleanFocus the first box on mount.
namestringSubmits the code with the surrounding form as one string (possibly partial).
requiredbooleanEvery box must be filled for the form to submit; the browser points at the first empty one.
labelsPartial<OTPInputLabels>Overrides for the built-in English text; keys left out keep their defaults.

Похожие компоненты

  • Number Input — Числовой ввод
  • Phone Input — Телефон с выбором страны, форматированием на лету и значением E.164
  • Masked Input — Ввод по маске: карты с Luhn, срок действия, CVC, дата, время
  • Text Input — Текстовые поля
  • Textarea — Многострочный ввод
  • Search Input — Поисковая строка
  • Mentions Input — Текст с @упоминаниями и #тегами, асинхронные подсказки
  • Tags Input — Ввод тегов
  • Select — Выбор из списка
  • Multi Select — Множественный выбор
  • Combobox — Поиск и выбор
  • Listbox — Список вариантов на странице: один или несколько, диапазоны с Shift

Назад: Number Input · Далее: Phone Input · Весь раздел «Формы и ввод»