Component

OTP 6-Digit Input

One-time password input components with verification code styling

  • Component
  • Tailwind
  • MIT

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.dev/library/tailwind/components/input/otp-6-digit/
fluid · no fixed width 100%
No dependencies Production-ready

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Input/otp-6-digit
registry path: Tailwind/Components/Input/otp-6-digit

Source

Implementation

code.html
<!-- OTP 6-Digit - Standard -->
<div>
  <label class="block text-sm font-medium text-gray-700 mb-3 text-center">Enter verification code</label>
  <div class="flex justify-center gap-2 sm:gap-3">
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-white border-2 border-gray-300 rounded-lg text-center text-xl font-bold focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-white border-2 border-gray-300 rounded-lg text-center text-xl font-bold focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-white border-2 border-gray-300 rounded-lg text-center text-xl font-bold focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-white border-2 border-gray-300 rounded-lg text-center text-xl font-bold focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-white border-2 border-gray-300 rounded-lg text-center text-xl font-bold focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-white border-2 border-gray-300 rounded-lg text-center text-xl font-bold focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 transition-colors" />
  </div>
  <p class="mt-4 text-sm text-gray-500 text-center">Code sent to your email</p>
</div>

<!-- OTP 6-Digit - Dark -->
<div class="mt-6 p-6 bg-slate-900 rounded-xl">
  <label class="block text-sm font-medium text-gray-300 mb-3 text-center">Enter 2FA Code</label>
  <div class="flex justify-center gap-2 sm:gap-3">
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-slate-800 border-2 border-slate-600 rounded-lg text-center text-xl font-bold text-white focus:outline-none focus:border-blue-400 focus:ring-2 focus:ring-blue-400/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-slate-800 border-2 border-slate-600 rounded-lg text-center text-xl font-bold text-white focus:outline-none focus:border-blue-400 focus:ring-2 focus:ring-blue-400/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-slate-800 border-2 border-slate-600 rounded-lg text-center text-xl font-bold text-white focus:outline-none focus:border-blue-400 focus:ring-2 focus:ring-blue-400/20 transition-colors" />
    <input type="text" maxlength="1" class="w-10 h-12 sm:w-12 sm:h-14 bg-slate-800 border-2 border-slate-600 rounded-lg text-center text-xl font-bold text-white focus:outline-none focus:border-blue-400 focus:ring-2 focus:ring-blue-400/20 transition-colors" />
  </div>
</div>

<!-- OTP 6-Digit - With Resend -->
<div class="mt-6 text-center">
  <label class="block text-sm font-medium text-gray-700 mb-3">One-Time Password</label>
  <div class="flex justify-center gap-2 mb-4">
    <input type="text" maxlength="1" class="w-11 h-13 bg-white border-2 border-gray-200 rounded-xl text-center text-lg font-bold focus:outline-none focus:border-green-500 focus:ring-2 focus:ring-green-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-11 h-13 bg-white border-2 border-gray-200 rounded-xl text-center text-lg font-bold focus:outline-none focus:border-green-500 focus:ring-2 focus:ring-green-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-11 h-13 bg-white border-2 border-gray-200 rounded-xl text-center text-lg font-bold focus:outline-none focus:border-green-500 focus:ring-2 focus:ring-green-500/20 transition-colors" />
    <input type="text" maxlength="1" class="w-11 h-13 bg-white border-2 border-gray-200 rounded-xl text-center text-lg font-bold focus:outline-none focus:border-green-500 focus:ring-2 focus:ring-green-500/20 transition-colors" />
  </div>
  <p class="text-sm text-gray-500">Didn't receive the code? <button class="text-blue-600 hover:text-blue-700 font-medium shrink-0 whitespace-nowrap">Resend</button></p>
</div>
36 lines UTF-8 · LF · Spaces: 2

AI-ready

Available to your agent.

This component is reachable through the DevSnips CLI, MCP server and Skills integrations — one registry, one resource path.

Resource path

devsnips://components/input/otp-6-digit

Continue browsing

View all