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
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
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State (required) | — | The |
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 |
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.