advanced forms
Tailwind CSS Pin Input
The Pin Input component enables quick entry for scenarios such as multi-factor authentication, offering features like regex validation and clipboard pasting.
Basic pin input example.
Pin input with placeholder.
Default pin input example.
Apply the pin-input-underline
class to change the pin input style to an underline.
Pin input has 3 size small default and large. Use pin-input-sm
for small size and pin-input-lg
for large size.
Underline pin input sizes example.
To disable pointer events and prevent focusing, add the disabled
boolean attribute to an input.
Control the number of pin input as per you preference.
By default, this accepts both letters and numbers. To restrict input to numbers/letters only, set "availableCharsRE"
to "^[a-z]+$"
/ "^[0-9]+$"
.
To restrict the pin input to accept only specific numbers, you can use a regular expression. For example, to ensure the pin input accepts only the numbers 1 to 5, set "availableCharsRE"
to "^[1-5]+$"
.
Conceal the entered value by setting the type attribute to “password”.
To display a numeric keyboard on iOS (note: this does not apply for Android), Use autocomplete="one-time-code"
and type="tel"
.
The destroy
method is provided to facilitate the destruction of a pin-input element.
HSPinInput
object is contained within the global window
object.Destroy instance.
Assign an ID to data-pin-input
, and you can then trigger an event using that ID.
Below is a demonstration of how to use the event. We’ve included JavaScript to handle the events, allowing it to execute when the corresponding event is fired. To test these events, monitor your console.
When pin input is completed example.