Input OTP
Accessible one-time password component with copy-paste functionality.
About
Input OTP is a port of input-otp by @guilherme_rodz.
Installation
Usage
<InputOtp MaxLength="6">
<InputOtpGroup>
<InputOtpSlot Index="0" />
<InputOtpSlot Index="1" />
<InputOtpSlot Index="2" />
</InputOtpGroup>
<InputOtpSeparator />
<InputOtpGroup>
<InputOtpSlot Index="3" />
<InputOtpSlot Index="4" />
<InputOtpSlot Index="5" />
</InputOtpGroup>
</InputOtp>Composition
Use the following composition to build an InputOtp:
InputOtp
├── InputOtpGroup
│ ├── InputOtpSlot
│ ├── InputOtpSlot
│ └── InputOtpSlot
├── InputOtpSeparator
├── InputOtpGroup
│ ├── InputOtpSlot
│ ├── InputOtpSlot
│ └── InputOtpSlot
├── InputOtpSeparator
└── InputOtpGroup
├── InputOtpSlot
└── InputOtpSlotPattern
Use the Pattern parameter to define a custom pattern for the OTP input.
<InputOtp MaxLength="6" Pattern="@InputOtpPatterns.OnlyDigitsAndChars">
...
</InputOtp>Separator
Use the <InputOtpSeparator /> component to add a separator between input groups.
Disabled
Use the Disabled parameter to disable the input.
Controlled
Use @bind-Value (or Value and ValueChanged) to control the input value.
Invalid
Use aria-invalid on the slots to show an error state.
Four Digits
A common pattern for PIN codes. This uses the Pattern="@InputOtpPatterns.OnlyDigits" parameter.
Alphanumeric
Use InputOtpPatterns.OnlyDigitsAndChars to accept both letters and numbers.
Form
RTL
To enable RTL support in Blazix, see the RTL configuration guide.
Translated with AI for the demo, so it may have mistakes.
API Reference
InputOtp
Other attributes are passed to the element it renders.
InputOtpGroup
Other attributes are passed to the element it renders.
InputOtpSlot
Other attributes are passed to the element it renders.
InputOtpSeparator
Other attributes are passed to the element it renders.