Modals

Copy-paste ready modal dialog components

← Back to Home

Basic Modal

Simple modal dialog with title and content

HTML
<button onclick="document.getElementById('modal').classList.remove('hidden')">
  Open Modal
</button>

<div id="modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
  <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
    <div class="mt-3">
      <h3 class="text-lg font-medium leading-6 text-gray-900">Modal Title</h3>
      <div class="mt-2 px-7 py-3">
        <p class="text-sm text-gray-500">This is a basic modal dialog.</p>
      </div>
      <div class="flex justify-end px-4 py-3">
        <button onclick="document.getElementById('modal').classList.add('hidden')" class="px-4 py-2 bg-gray-500 text-white text-sm rounded-md">
          Close
        </button>
      </div>
    </div>
  </div>
</div>

Confirmation Modal

Modal with confirm and cancel actions

HTML
<div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
  <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
    <div class="mt-3">
      <div class="flex items-center justify-center w-12 h-12 mx-auto bg-red-100 rounded-full">
        <svg class="w-6 h-6 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
        </svg>
      </div>
      <h3 class="text-lg font-medium text-gray-900 text-center mt-4">Delete Confirmation</h3>
      <div class="mt-2 px-7 py-3">
        <p class="text-sm text-gray-500 text-center">Are you sure you want to delete this item?</p>
      </div>
      <div class="flex gap-3 px-4 py-3">
        <button class="flex-1 px-4 py-2 bg-gray-300 text-gray-700 text-sm rounded-md">Cancel</button>
        <button class="flex-1 px-4 py-2 bg-red-600 text-white text-sm rounded-md">Delete</button>
      </div>
    </div>
  </div>
</div>

Form Modal

Modal containing a form

HTML
<div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
  <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
    <div class="flex items-center justify-between mb-4">
      <h3 class="text-lg font-medium text-gray-900">Add New User</h3>
      <button class="text-gray-400 hover:text-gray-600">
        <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">...</svg>
      </button>
    </div>
    <form class="space-y-4">
      <div>
        <label class="block text-sm font-medium text-gray-700 mb-1">Name</label>
        <input type="text" class="w-full px-3 py-2 border rounded-md">
      </div>
      <div class="flex justify-end gap-3 pt-4">
        <button type="button" class="px-4 py-2 bg-gray-300 text-gray-700 rounded-md">Cancel</button>
        <button type="submit" class="px-4 py-2 bg-green-600 text-white rounded-md">Add User</button>
      </div>
    </form>
  </div>
</div>

Large Modal

Wider modal for more content

HTML
<div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
  <div class="relative top-20 mx-auto p-5 border max-w-2xl shadow-lg rounded-md bg-white">
    <div class="flex items-center justify-between mb-4">
      <h3 class="text-xl font-medium text-gray-900">Large Modal Title</h3>
      <button class="text-gray-400 hover:text-gray-600">
        <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">...</svg>
      </button>
    </div>
    <div class="space-y-4">
      <p class="text-sm text-gray-500">Content goes here...</p>
    </div>
    <div class="flex justify-end gap-3 mt-6">
      <button class="px-4 py-2 bg-gray-300 text-gray-700 rounded-md">Close</button>
    </div>
  </div>
</div>

Success Modal

Modal with success message and icon

HTML
<div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
  <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
    <div class="mt-3 text-center">
      <div class="flex items-center justify-center w-12 h-12 mx-auto bg-green-100 rounded-full">
        <svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
        </svg>
      </div>
      <h3 class="text-lg font-medium text-gray-900 mt-4">Success!</h3>
      <div class="mt-2 px-7 py-3">
        <p class="text-sm text-gray-500">Your changes have been saved.</p>
      </div>
      <div class="flex justify-center px-4 py-3">
        <button class="px-6 py-2 bg-green-600 text-white text-sm rounded-md">Continue</button>
      </div>
    </div>
  </div>
</div>

Scrollable Modal

Modal with scrollable content

HTML
<div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
  <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
    <div class="flex items-center justify-between mb-4">
      <h3 class="text-lg font-medium text-gray-900">Terms and Conditions</h3>
      <button class="text-gray-400 hover:text-gray-600">
        <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">...</svg>
      </button>
    </div>
    <div class="max-h-96 overflow-y-auto px-2">
      <p class="text-sm text-gray-600">Long scrollable content...</p>
    </div>
    <div class="flex justify-end gap-3 mt-4 pt-4 border-t">
      <button class="px-4 py-2 bg-gray-300 text-gray-700 rounded-md">Decline</button>
      <button class="px-4 py-2 bg-indigo-600 text-white rounded-md">Accept</button>
    </div>
  </div>
</div>