Component

OTP Verification Modal

One-time password verification modal with individual digit inputs, countdown timer, and alternative verification methods.

  • Component
  • Tailwind
  • HTML
  • MIT

Preview

Live component

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

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Modals/otp-verification-modal
registry path: Tailwind/Components/Modals/otp-verification-modal

Source

Implementation

code.html
<!-- OTP Verification Modal -->
<div id="otp-modal" class="fixed inset-0 z-50 hidden">
  <!-- Backdrop -->
  <div class="fixed inset-0 bg-black/50 backdrop-blur-sm" onclick="closeModal('otp-modal')"></div>
  
  <!-- Modal Container -->
  <div class="fixed inset-0 flex items-center justify-center p-4">
    <div class="relative bg-white dark:bg-gray-900 rounded-2xl shadow-2xl w-full max-w-md transform transition-all" role="dialog" aria-modal="true" aria-labelledby="otp-modal-title">
      
      <!-- Header -->
      <div class="p-6 pb-0 text-center">
        <div class="w-16 h-16 bg-teal-100 dark:bg-teal-900/30 rounded-2xl flex items-center justify-center mx-auto mb-4">
          <svg class="w-8 h-8 text-teal-600 dark:text-teal-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
          </svg>
        </div>
        <h3 id="otp-modal-title" class="text-2xl font-bold text-gray-900 dark:text-white">Verify Your Account</h3>
        <p class="text-gray-500 dark:text-gray-400 mt-2">We've sent a code to <span class="font-medium text-gray-700 dark:text-gray-300">alex***@company.com</span></p>
      </div>
      
      <!-- Form -->
      <form class="p-6" onsubmit="event.preventDefault(); closeModal('otp-modal');">
        <!-- OTP Inputs -->
        <div class="flex justify-center gap-3 mb-6">
          <input type="text" maxlength="1" class="w-14 h-16 text-center text-2xl font-bold border-2 border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-teal-500 focus:border-transparent transition-all" autofocus>
          <input type="text" maxlength="1" class="w-14 h-16 text-center text-2xl font-bold border-2 border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-teal-500 focus:border-transparent transition-all">
          <input type="text" maxlength="1" class="w-14 h-16 text-center text-2xl font-bold border-2 border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-teal-500 focus:border-transparent transition-all">
          <input type="text" maxlength="1" class="w-14 h-16 text-center text-2xl font-bold border-2 border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-teal-500 focus:border-transparent transition-all">
        </div>
        
        <!-- Timer -->
        <div class="text-center mb-6">
          <p class="text-sm text-gray-500 dark:text-gray-400">
            Didn't receive the code? 
            <button type="button" class="text-teal-600 dark:text-teal-400 font-medium hover:underline disabled:opacity-50 disabled:cursor-not-allowed" disabled id="resend-btn">Resend in 30s</button>
          </p>
        </div>
        
        <!-- Submit -->
        <button type="submit" class="w-full py-4 bg-gradient-to-r from-teal-500 to-emerald-600 text-white font-semibold rounded-xl hover:from-teal-600 hover:to-emerald-700 transition-all focus:outline-none focus:ring-2 focus:ring-teal-500 focus:ring-offset-2 shadow-lg shadow-teal-500/30">Verify OTP</button>
      </form>
      
      <!-- Alternative Methods -->
      <div class="px-6 pb-6">
        <div class="flex items-center gap-4 mb-4">
          <div class="flex-1 h-px bg-gray-200 dark:bg-gray-700"></div>
          <span class="text-sm text-gray-500 dark:text-gray-400">or verify with</span>
          <div class="flex-1 h-px bg-gray-200 dark:bg-gray-700"></div>
        </div>
        
        <button class="w-full flex items-center justify-center gap-3 py-3 border border-gray-200 dark:border-gray-700 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors">
          <svg class="w-5 h-5" viewBox="0 0 24 24">
            <path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
            <path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
            <path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/>
            <path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
          </svg>
          <span class="text-sm font-medium text-gray-700 dark:text-gray-300">Google Authenticator</span>
        </button>
      </div>
    </div>
  </div>
</div>

<!-- Demo Trigger Button -->
<button onclick="openModal('otp-modal')" class="px-6 py-3 bg-gradient-to-r from-teal-500 to-emerald-600 text-white font-medium rounded-xl hover:from-teal-600 hover:to-emerald-700 transition-all focus:outline-none focus:ring-2 focus:ring-teal-500 focus:ring-offset-2">Open OTP Modal</button>
66 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/modals/otp-verification-modal

Continue browsing

View all