Ship faster with goilerplate templUI Pro

Input OTP

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

Source Tailwind CSS JavaScript

Installation

templui add inputotp

Load the script once in your layout:

<head>
  @inputotp.Script()
</head>

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

Unique identifier for the OTP input component

string
""
Class

Additional CSS classes to apply to the container

string
""
Attributes

Additional HTML attributes to apply to the container

templ.Attributes
nil
Value

Current value of the OTP input

string
""
Name

Name attribute for the hidden input field

string
""
HasError

Whether the OTP input should display error styling

bool
false

Group

Container for grouping OTP slots together.

Name Type Default
ID

Unique identifier for the group element

string
""
Class

Additional CSS classes to apply to the group

string
""
Attributes

Additional HTML attributes to apply to the group

templ.Attributes
nil

Slot

Individual input slot for a single character.

Name Type Default
ID

Unique identifier for the slot element

string
""
Class

Additional CSS classes to apply to the slot

string
""
Attributes

Additional HTML attributes to apply to the slot

templ.Attributes
nil
Index

Index position of this slot in the OTP sequence

int
0
Type

Input type for the slot (text or password)

string
text
Placeholder

Placeholder text for the slot

string
""
Disabled

Whether the slot is disabled

bool
false

Separator

Visual separator between groups of slots.

Name Type Default
ID

Unique identifier for the separator element

string
""
Class

Additional CSS classes to apply to the separator

string
""
Attributes

Additional HTML attributes to apply to the separator

templ.Attributes
nil