- Components
- otp
Otp / Pin
Segmented input field designed for verification codes and MFA.
Demo
<x-ui.otp class="max-w-xs">
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
</x-ui.otp>
Installation
-
Add the component
Shellflexi-cli add otp -
Install Otp Plugin
This component require JS. By default we're using our own Interactive Component Library Flexilla . Install this only if you didn't accept dependencies installation during component addition.- With Alpine
- Without Alpine
Shellnpm i @flexilla/alpine-pin-inputAdd plugin in
flexilla.jsflexilla.jsimport AlpinePinInput from "@flexilla/alpine-pin-input" Alpine.plugin(AlpinePinInput)Make sure that the dropdown package is not installedShellnpm i @flexilla/pin-inputInitialize Pin Input in
flexilla.jsflexilla.jsimport { PinInput} from "@flexilla/pin-input" // init Pin Input for all Element with data-app-otp attribute PinInput.autoInit('[data-app-otp]')
Examples
Numeric OTP
<x-ui.otp validation="number" class="max-w-xs">
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
</x-ui.otp>
Alphabetic OTP
<x-ui.otp validation="alpha" class="max-w-xs">
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
</x-ui.otp>
Alpha Numeric OTP
<x-ui.otp validation="alphanumeric" class="max-w-xs">
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
<x-ui.otp.input size="none" class="size-10 max-w-10" />
</x-ui.otp>
References
OTP Component
The OTP (One-Time Password) component creates a group of input fields designed for entering verification codes. It provides built-in validation and auto-focus management between fields.
OTP Container
| Prop | Type | Default | Description |
|---|---|---|---|
validation
|
string | null |
Defines the input validation pattern. Can be one of:
|
class
|
string | '' |
Additional CSS classes for the OTP container.
|
OTP Input
| Prop | Type | Default | Description |
|---|---|---|---|
size
|
string | 'md' |
Controls the size of the input. Can be one of: 'xs', 'sm', 'md', 'lg', 'xl'.
|
type
|
string | 'text' |
The HTML input type. Typically 'text' or 'password'.
|
radius
|
string | 'lg' |
Border radius of the input. Can be one of: 'none', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', 'full'.
|
disabled
|
boolean | false |
When true, the input is disabled and not interactive.
|
readonly
|
boolean | false |
When true, the input is read-only and cannot be modified.
|
noBorder
|
boolean | false |
When true, removes the border from the input.
|
unStylled
|
boolean | false |
When true, removes all default styling from the input.
|
JavaScript API
The OTP component is powered by the @flexilla/pin-input
package.
For advanced usage and methods, refer to the
Flexilla Pin Input
Documentation
.
Accessibility
The OTP component is built with accessibility in mind:
- Proper ARIA attributes for screen readers
- Keyboard navigation support (Tab, Shift+Tab, Arrow keys)
- Auto-focus management between fields
- Paste support for easier code entry