@jasen
To create a dropdown menu in Tailwind CSS, you can use the built-in utility classes to style the menu items and the behavior of the dropdown. Here's a step-by-step guide to create a basic dropdown menu:
1 2 3 4 5 6 7 8 9 10 |
<div class="relative"> <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"> Dropdown </button> <div class="absolute hidden bg-white rounded shadow-md"> <a href="#" class="block hover:bg-gray-200 text-gray-800 py-2 px-4">Item 1</a> <a href="#" class="block hover:bg-gray-200 text-gray-800 py-2 px-4">Item 2</a> <a href="#" class="block hover:bg-gray-200 text-gray-800 py-2 px-4">Item 3</a> </div> </div> |
1 2 3 |
document.querySelector('.relative').addEventListener('click', function() { document.querySelector('.absolute').classList.toggle('hidden'); }); |
This is a basic example of creating a dropdown menu in Tailwind CSS. You can further enhance and customize the dropdown menu by adding animations, transitions, or other features using Tailwind CSS utility classes.