Docs

Cinder UI

Forms.input_otp

Progressive

Renders an OTP-style segmented input layout.

This component renders one input per position and can be wired using standard Phoenix input names such as code[]. The bundled CuiInputOtp hook adds auto-advance, backspace-to-previous, and paste distribution behavior.

With FormField (string value is split into individual cells)

<.input_otp field={@form[:code]} length={6} />

With label

<.input_otp field={@form[:code]} label="Verification code" length={6} />

With explicit errors

<.input_otp field={@form[:code]} label="Verification code" errors={["is invalid"]} length={6} />

Inside field composition

<.field>
  <:label><.label for={@form[:code].id}>Verification code</.label></:label>
  <.input_otp field={@form[:code]} length={6} />
  <:description>Enter the 6-digit code from your email.</:description>
</.field>

Basic OTP input

  <.input_otp name="verification_code[]" length={6} />

With grouped separators

-
  <.input_otp name="backup_code[]" length={6} groups={[3, 3]} values={["1", "2", "3", "4", "5", "6"]} />

Attributes

Name Type Default Values Global Includes
class :string
errors :list
field {:struct, Phoenix.HTML.FormField}
groups :list []
id :string
input_class :string
label :string
length :integer 6
name :string "code[]"
rest :global
values :list []

Slots

No slots declared.