Design a Guestbook in Tailwind CSS Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The Guestbook is a web application designed to collect guest information including their name, address, mobile number, and room number. It provides a simple and intuitive interface for the users to input their details and view them in a list format. PrerequisitesHTMLTailwind CSSJavaScriptApproachIn this approach, we are Creating a form with Name, address, Mobile no, and room number. On submitting that information it will append a div to the bottom of the form and the field of the form will get empty for further information.By using the classes of Tailwind CSS we are making it responsive for small devices.We are creating a delete button for every guest so that we can delete that guest. We are also creating a Delete All button that will delete all the guest list at once.Example: This example shows the implementation of the above-explained appraoch. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>The Guestbook</title> <link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet"> <style> body { background-color: #48bb78; } .guest-form-container { max-height: 80vh; overflow-y: auto; } </style> </head> <body class="flex justify-center items-center h-screen"> <div class="container mx-auto md:w-1/2 bg-white p-8 rounded-lg shadow-md guest-form-container"> <h1 class="text-3xl font-bold text-center mb-8" >Guestbook</h1> <form id="guestForm" class="space-y-4"> <div class="flex flex-col"> <label for="name" class="text-gray-700"> Name:</label> <input type="text" id="name" name="name" required class="border border-gray-300 rounded-md px-4 py-2 focus:outline-none focus:border-blue-500"> </div> <div class="flex flex-col"> <label for="address" class="text-gray-700"> Address:</label> <input type="text" id="address" name="address" required class="border border-gray-300 rounded-md px-4 py-2 focus:outline-none focus:border-blue-500"> </div> <div class="flex flex-col"> <label for="mobile" class="text-gray-700"> Mobile:</label> <input type="tel" id="mobile" name="mobile" required pattern="[0-9]*" class="border border-gray-300 rounded-md px-4 py-2 focus:outline-none focus:border-blue-500"> </div> <div class="flex flex-col"> <label for="roomno" class="text-gray-700"> Room Number:</label> <input type="text" id="roomno" name="roomno" required class="border border-gray-300 rounded-md px-4 py-2 focus:outline-none focus:border-blue-500"> </div> <div class="flex justify-between"> <button type="submit" class="bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 focus:outline-none"> Add Guest</button> <button id="clearBtn" class="bg-red-500 text-white py-2 px-4 rounded-md hover:bg-red-600 focus:outline-none"> Clear All</button> </div> </form> <div id="guestList" class="mt-8"></div> </div> <script> const guestForm = document.getElementById('guestForm'); const guestList = document.getElementById('guestList'); function createGuestCard(name, address, mobile, roomno) { const guestCard = document.createElement('div'); guestCard.classList.add('bg-gray-200', 'p-4', 'rounded-md', 'mb-4'); guestCard.innerHTML = ` <h2 class="text-xl font-bold">${name}</h2> <p><strong>Address:</strong> ${address}</p> <p><strong>Mobile:</strong> ${mobile}</p> <p><strong>Room Number:</strong> ${roomno}</p> <div class="flex justify-between mt-2"> <button class="bg-red-500 text-white px-3 py-1 rounded-md hover:bg-red-600 focus:outline-none delete-btn">Delete</button> </div>`; return guestCard; } function addGuest(name, address, mobile, roomno) { const guestCard = createGuestCard(name, address, mobile, roomno); guestList.appendChild(guestCard); } function clearGuests() { guestList.innerHTML = ''; } guestForm.addEventListener('submit', function (e) { e.preventDefault(); const name = document.getElementById('name').value; const address = document.getElementById('address').value; const mobile = document.getElementById('mobile').value; const roomno = document.getElementById('roomno').value; addGuest(name, address, mobile, roomno); guestForm.reset(); }); guestList.addEventListener('click', function (e) { if (e.target.classList.contains('delete-btn')) { e.target.closest('.bg-gray-200').remove(); } }); const clearBtn = document.getElementById('clearBtn'); clearBtn.addEventListener('click', clearGuests); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article Design a Guestbook in Tailwind CSS M mguru4c05q Follow Improve Article Tags : JavaScript Web Technologies CSS Tailwind CSS Similar Reads Design a Google Template in Tailwind CSS The Tailwind CSS is a popular utility-first CSS framework that provides low-level utility classes to the style web applications. Using Tailwind CSS we will design a Google template. The template will mimic the layout and styling of Google's search engine's homepage. Output Preview: Let us have a loo 2 min read Design a Survey Form in Tailwind CSS In this project, we'll create a survey form using the HTML and style it with the Tailwind CSS. The survey form will collect user information such as name, email, age, role, recommendations known languages and frameworks, and comments or suggestions.Example: Implemenattion to design a survey form usi 3 min read Design a Login Modal in Tailwind CSS Tailwind CSS allows us to design styled and responsive awesome applications using pre-defined classes that enhance the look and feel of the application. For designing the Login Modal in Tailwind CSS, we can use utility classes that build the responsive user interface and clean elements. ApproachCrea 4 min read Tailwind CSS Position This class accepts more than one value in tailwind CSS. It is the alternative to the CSS Position property. This class is used for controlling how an element is positioned in the DOM.Position classes:staticfixedabsoluterelativestickystatic: This class is used to set the position of an element accord 4 min read Tailwind CSS Height This class accepts lots of values in tailwind CSS in which all the properties are covered in class form. Â It is the alternative to the CSS height Property. This class is used to set the height of an element. The height class does not contain padding, margin, and the border of elements.Height classes 3 min read Like