Reference

InputOTP

A one-time code typed a digit to a box: the focus moves on as each is typed and back with Backspace, and a code pasted into any box fills them all; the browser offers the code it was sent (autocomplete="one-time-code").

InputOTP(bind: State, length: Number, label: String)

Since 6.2.0

length

label

6 digit(s) to go

Example

wf

state code = "" derived left = 6 - code.length InputOTP(bind: code, length: 6, label: "Code from your authenticator app") Text(if code.length == 6 { "Checking {code}…" } else { "{left} digit(s) to go" }).muted

Props

Props of InputOTP
PropTypeUnsetMeaning

bind:

State (required)

—

The String state it reads and writes: the digits typed so far, in order; anything but a digit is dropped

length:

Number

6

How many boxes, one digit each

label:

String (required)

—

What the code is: the group's name for a screen reader; each box is named Digit 1 of 6

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

No flags of its own.

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Renders with the class wf-otp, stable across releases, so a stylesheet may target it.