Unknown model· unknown
from ShareGPT 90K (shared ChatGPT conversations)
How to make a hamburger nav menu for mobile screen size in tailwind css with nextjs
- User
How to make a hamburger nav menu for mobile screen size in tailwind css with nextjs
- Assistant
To make a hamburger navigation menu for mobile screen size in Tailwind CSS with Next.js, you can follow these steps:
- Create a navigation component in Next.js:
javascript// components/Navigation.js import Link from 'next/link'; const Navigation = () => { return ( <nav className="flex items-center justify-between flex-wrap bg-gray-800 p-6"> <div className="flex items-center flex-shrink-0 text-white mr-6"> <span className="font-semibold text-xl tracking-tight">My Site</span> </div> <div className="block lg:hidden"> <button className="flex items-center px-3 py-2 border rounded text-gray-200 border-gray-400 hover:text-white hover:border-white"> <svg className="h-3 w-3 fill-current" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><title>Menu</title><path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"/></svg> </button> </div> <div className="w-full block flex-grow lg:flex lg:items-center lg:w-auto"> <div className="text-sm lg:flex-grow"> <Link href="/"> <a className="block mt-4 lg:inline-block lg:mt-0 text-gray-200 hover:text-white mr-4"> Home </a> </Link> <Link href="/about"> <a className="block mt-4 lg:inline-block lg:mt-0 text-gray-200 hover:text-white mr-4"> About </a> </Link> <Link href="/contact"> <a className="block mt-4 lg:inline-block lg:mt-0 text-gray-200 hover:text-white"> Contact </a> </Link> </div> </div> </nav> ); }; export default Navigation;