templUI Pro coming soon  

50% OFF Join Waitlist

Input OTP

Input field for one-time password/verification code entry.

Source
TailwindCSS
Vanilla JS

Installation

  1. Install the component

    templui add inputotp
  2. Add the JavaScript to your layout

    @inputotp.Script()
    

    Call this template in your base layout file (e.g., in the <head> section).

Examples

Placeholder

-

With Label

Custom Length

Password Type

-

Custom Styling

-

Form

-

Enter the 6-digit code sent to your phone

Invalid verification code.

API Reference

Required parameter
Hover for description

InputOTP

Main container for the OTP input component.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil
Value
string
""
Required
bool
false
Name
string
""
HasError
bool
false

Group

Container for grouping OTP slots together.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil

Slot

Individual input slot for a single character.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil
Index
int
0
Type
string
text
Placeholder
string
""
Disabled
bool
false

Separator

Visual separator between groups of slots.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil