Skip to main content

OTP Field

Enter a one-time code one character at a time, built on Base UI.

View as Markdown

Installation

Component API

PropTypeDefaultDescription
labelstring-Text above the slots, wired to the first one through Base UI's Field.Label.
Text above the slots, wired to the first one through Base UI's Field.Label.
descriptionstring-A line under the slots, for where the code comes from.
A line under the slots, for where the code comes from.
errorstring-The code was wrong: the slots shake, the digits clear, and this message takes the place of description.
The code was wrong: the slots shake, the digits clear, and this message takes the place of description.
successstring-The code was right: the slots turn green, then fold into a key with this text.
The code was right: the slots turn green, then fold into a key with this text.
lengthnumber6How many characters the code has, one slot each.
How many characters the code has, one slot each.
groupSizenumber3
validationTypenumeric | alpha | alphanumericnumeric
maskbooleanfalseDraws each character as a dot, as a password field does.
Draws each character as a dot, as a password field does.
sizesm | md | lgmdWidth, height and type size of every slot.
Width, height and type size of every slot.
shapenone | rounded | pillrounded
disabledbooleanfalseBlocks input and dims the whole field, label included.
Blocks input and dims the whole field, label included.
requiredbooleanfalseAppends a red asterisk to the label and makes the code required when a form submits.
Appends a red asterisk to the label and makes the code required when a form submits.
classNamestring-
focusboolean | stringtrue