Toggle navigation
☰
HTML
CSS
Scripting
Database
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS Navbar With Mega Menu</title> <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.2.1"></script> </head> <body class="bg-slate-50"> <nav class="bg-white border-b border-slate-200" x-data="{ open: false, megaMenu: false }"> <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> <div class="flex justify-between h-20"> <div class="flex items-center"> <a href="##" class="text-2xl font-black text-slate-900 tracking-tight">TECHHUB</a> <!-- Desktop Navigation --> <div class="hidden md:ml-10 md:flex md:space-x-8 h-full"> <a href="##" class="inline-flex items-center text-sm font-semibold text-slate-600 hover:text-blue-600 transition">Products</a> <!-- Mega Menu Trigger --> <button @mouseenter="megaMenu = true" @mouseleave="megaMenu = false" class="inline-flex items-center text-sm font-semibold text-slate-600 hover:text-blue-600 focus:outline-none transition" > <span>Solutions</span> <svg class="ml-1 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /> </svg> </button> <a href="##" class="inline-flex items-center text-sm font-semibold text-slate-600 hover:text-blue-600 transition">Resources</a> </div> </div> <!-- Mobile Toggler --> <div class="flex items-center md:hidden"> <button @click="open = !open" class="p-2 rounded-md text-slate-400 hover:text-slate-500 hover:bg-slate-100"> <svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" /> </svg> </button> </div> </div> </div> <!-- Mega Menu Container (Desktop) --> <div x-show="megaMenu" @mouseenter="megaMenu = true" @mouseleave="megaMenu = false" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 translate-y-1" x-transition:enter-end="opacity-100 translate-y-0" class="absolute inset-x-0 top-20 bg-white shadow-2xl z-50 border-b border-slate-200 hidden md:block" style="display: none;" > <div class="max-w-7xl mx-auto grid grid-cols-4 gap-8 p-12"> <div> <h3 class="text-xs font-bold text-slate-400 uppercase tracking-widest mb-4">Cloud Services</h3> <ul class="space-y-3"> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Compute Instances</a></li> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Object Storage</a></li> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Global CDN</a></li> </ul> </div> <div> <h3 class="text-xs font-bold text-slate-400 uppercase tracking-widest mb-4">Data Engine</h3> <ul class="space-y-3"> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Managed Database</a></li> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Analytics Workspace</a></li> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Data Pipeline</a></li> </ul> </div> <div> <h3 class="text-xs font-bold text-slate-400 uppercase tracking-widest mb-4">AI & Machine Learning</h3> <ul class="space-y-3"> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Model Training</a></li> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Speech to Text</a></li> <li><a href="##" class="text-slate-600 hover:text-blue-600 font-medium text-sm">Vision APIs</a></li> </ul> </div> <div class="bg-slate-50 rounded-2xl p-6"> <h3 class="text-sm font-bold text-slate-900 mb-2">New: Quantum Beta</h3> <p class="text-sm text-slate-500 mb-4">Experience the future of computing today with our new quantum instances.</p> <a href="##" class="text-sm font-bold text-blue-600 hover:text-blue-700">Learn more →</a> </div> </div> </div> <!-- Mobile Menu --> <div class="md:hidden" x-show="open" @click.away="open = false"> <div class="px-4 py-6 space-y-4"> <a href="##" class="block text-lg font-bold text-slate-800">Products</a> <div x-data="{ expanded: false }"> <button @click="expanded = !expanded" class="w-full flex justify-between items-center text-lg font-bold text-slate-800 focus:outline-none"> <span>Solutions</span> <svg class="h-5 w-5 transition-transform" :class="{'rotate-180': expanded}" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" /> </svg> </button> <div x-show="expanded" class="mt-4 pl-4 space-y-3 italic text-slate-600 border-l-2 border-slate-100"> <a href="##" class="block">Cloud Services</a> <a href="##" class="block">Data Engine</a> <a href="##" class="block">AI & ML</a> </div> </div> <a href="##" class="block text-lg font-bold text-slate-800 text-blue-600">Resources</a> </div> </div> </nav> <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> </body> </html>