Open In App

How to create Cookies Message Popup Template in Tailwind CSS ?

The popup informs users about the website's use of cookies and provides options for cookie preferences. The simple and functional cookie message Popup where users can either accept all cookies or customize their settings by clicking on the respective buttons. The Tailwind CSS classes are used to style various elements. These classes enable quick and efficient styling, making the interface responsive to different screen sizes.

Approach to Create Cookies Message Popup Template in Tailwind

Example: Illustration of Designing a Cookies Message Popup Template in Tailwind CSS

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>Cookies Message Popup</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>

<body>
    <div class="fixed bottom-20 left-1/2 transform -translate-x-1/2 
                bg-black bg-opacity-80 text-white px-6 py-8 rounded-lg
                max-w-md w-11/12">
        <h2 class="text-2xl font-semibold mb-4">
              Cookies Message Popup
          </h2>
        <p class="text-lg mb-6">
          This website uses cookies to ensure you get the
          best experience on our website.
          </p>
        <button class="bg-green-500 text-white px-6 py-3 rounded-md
                       mr-4 transition-colors hover:bg-green-600 
                       focus:outline-none"
                   onclick="acceptCookies()">
              Accept All Cookies
          </button>
        <button class="bg-gray-700 text-white px-6 py-3 rounded-md
                       transition-colors hover:bg-gray-800 
                       focus:outline-none"
                onclick="showSettings()">
          Customize Settings
          </button>
    </div>
    <script>
        function acceptCookies() {
            alert("Cookies accepted!");
        }
        function showSettings() {
            alert("Customize settings page will be displayed.");
        }
    </script>
</body>

</html>

Output:

Cookies Message Popup Template

Cookies Message Popup Template

Article Tags :