Components
Toggle sidebar

OTP Input

Capture one-time passwords with a series of individual input fields.

Copy to clipboard
import { Otp } from '@fluxui-dev/react';<Otp length={6} />

Example usage

Display a form for verifying one-time passwords.

Copy to clipboard
import { Button, Card, Field, Heading, Otp, Text } from '@fluxui-dev/react';import { useState } from 'react';const [code, setCode] = useState('');const [error, setError] = useState<string>();<Card>    <form        className="space-y-8"        onSubmit={(event) => {            event.preventDefault();            setError(code.length === 6 ? undefined : 'The code field must be 6 characters.');        }}    >        <div className="mx-auto max-w-64 space-y-2">            <Heading size="lg" className="text-center">Verify your account</Heading>            <Text className="text-center">Please enter a one-time password from the authenticator app.</Text>        </div>        <Field error={error}>            <Field.Label srOnly>OTP Code</Field.Label>            <Otp value={code} onValueChange={setCode} length={6} className="mx-auto" />            <Field.Error icon={null} className="text-center" />        </Field>        <div className="space-y-4">            <Button variant="primary" type="submit" className="w-full">Verify</Button>            <Button className="w-full">Resend code</Button>        </div>    </form></Card>

Autosubmit

Use the submit="auto" prop to automatically submit the form once all input fields are filled.

Copy to clipboard
const [code, setCode] = useState('');<form    className="space-y-8"    onSubmit={(event) => {        event.preventDefault();        setCode('');    }}>    <div className="mx-auto max-w-64 space-y-2">        <Heading size="lg" className="text-center">Verify your account</Heading>        <Text className="text-center">Please enter a one-time password from the authenticator app.</Text>    </div>    <div className="space-y-6">        <Otp value={code} onValueChange={setCode} length={6} submit="auto" className="mx-auto" />    </div></form>

Alphanumeric

Allow non-numeric characters by setting the mode to alphanumeric or alpha.

Copy to clipboard
<Otp length={10} mode="alphanumeric" label="License key" descriptionTrailing="Enter the license key printed on the installation disc" />

Private

To mask sensitive input values, use the private prop.

Copy to clipboard
<Otp length={4} private label="PIN Code" />

Separator

Use children to render input fields with a separator in between them.

Copy to clipboard
<Otp>    <Otp.Input />    <Otp.Input />    <Otp.Input />    <Otp.Separator />    <Otp.Input />    <Otp.Input />    <Otp.Input /></Otp>

Group

Group all input fields together using the Otp.Group component.

Copy to clipboard
<Otp>    <Otp.Group>        <Otp.Input />        <Otp.Input />        <Otp.Input />        <Otp.Input />        <Otp.Input />        <Otp.Input />    </Otp.Group></Otp>

Group separator

Add a separator between groups of input fields using the Otp.Separator component.

Copy to clipboard
<Otp>    <Otp.Group>        <Otp.Input />        <Otp.Input />        <Otp.Input />    </Otp.Group>    <Otp.Separator />    <Otp.Group>        <Otp.Input />        <Otp.Input />        <Otp.Input />    </Otp.Group></Otp>

Reference

Otp

Prop
Description
value
The current value as a string. Pair with onValueChange.
defaultValue
Initial value of the code when uncontrolled.
onValueChange
Callback fired with the new code string whenever it changes.
onValueComplete
Callback fired with the code once every cell is filled.
length
The number of input fields to display.
mode
The input mode. Can be numeric (default), alphanumeric, or alpha. Letters are uppercased.
private
Masks the input values, as a password input does.
submit
Keyboard behavior for form submission. Options: (default), auto to submit when all fields are filled.
name
Name under which the code is submitted with the enclosing form.
autoComplete
The autocomplete attribute for the code. Use off to disable browser autofill. Default: one-time-code.
autoFocus
Focuses the first empty cell when the component mounts.
invalid
Styles every cell as invalid and sets aria-invalid. Passing an error does the same.
disabled
If true, prevents interaction with every cell.
readOnly
If true, the code can be focused but not changed.
label
Label text shown above the cells, wrapping Otp in a Field.
description
Description text shown between the label and the cells.
descriptionTrailing
Description text shown below the cells.
error
Error message shown below the cells, marking them invalid and defaulting to the validation error for the Otp's name.
children
Custom input fields and separators. When used, the length prop is ignored.
className
CSS classes applied to the row of cells. With label set, they stay on the row, below the label; to space the whole field, write the Field yourself and pass it className.
Attribute
Description
data-flux-otp
Applied to the element that holds the cells.

Otp.Input

CSS
Description
className
CSS classes applied to the cell's wrapper element.
inputClassName
CSS classes applied to the cell's input element.
Attribute
Description
data-flux-otp-input
Applied to each cell's input element.

Otp.Separator

Prop
Description
children
Content shown in place of the default em dash.

Otp.Group

Slot
Description
children
The input fields to include in the group.
Copyright © 2026 Wireable LLC ·Terms of Service
Built with by
Caleb Porzio and Hugo Sainte-Marie