Set length and render that many InputOTPSlots. Put the code in a Field with one FieldLabel: the first slot takes the label.
The sample also uses Field. One command adds them with this item:
sign-in-code.tsx
InputOTP
<div>| Prop | Type | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| class | string | — | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size | "default""lg""sm" | "default" | The size of every slot: sm 28, default 32, lg 36. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slot | characterLabel | The accessible name of each slot after the first, which takes the field label. Default: "Character 2 of 6". Translate it with the page. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From Base UIOtpField.RootBase UI docs | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id | string | — | The id of the first input element. Subsequent inputs derive their ids from it ({id}-2, {id}-3, and so on). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto | string | 'one-time-code' | The input autocomplete attribute. Applied to the first slot and hidden validation input. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| form | string | — | A string specifying the form element with which the hidden input is associated. This string's value must match the id of a form element in the same document. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
InputOTPGroup
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
InputOTPSlot
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
InputOTPSeparator
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
From Base UISeparatorBase UI docs | |||
| orientation | "horizontal""vertical" | 'horizontal' | The orientation of the separator. |
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
| ← | Moves to the slot before. |
|---|---|
| → | Moves to the slot after. |
| Home | Moves to the first slot. |
| End | Moves to the first empty slot, or the last slot. |
| Backspace | Deletes a character and moves to the slot before. |
| Delete | Deletes the character in the slot. |
| CtrlBackspace | Clears the code (⌘ Backspace on a Mac). |



