The Navbar component provides the main navigation for the ShipFree website, featuring a responsive design with mobile menu support.
import Navbar from "@/app/(site)/Navbar";
export default function Layout() {
return (
<div>
<Navbar />
{/* Other content */}
</div>
);
}
The Navbar component doesn’t accept any props as it’s a self-contained component.
"use client";
import Link from "next/link";
import { Zap, X } from "lucide-react";
import { useEffect, useState } from "react";
import { getGitHubStars } from "@/utils/github";
export default function Navbar() {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const [stars, setStars] = useState<number | null>(null);
// Toggle mobile menu
const toggleMenu = () => setIsMenuOpen(!isMenuOpen);
// Fetch GitHub stars
useEffect(() => {
getGitHubStars().then(setStars);
}, []);
return <nav>{/* Navigation content */}</nav>;
}
The component uses Tailwind CSS for styling with:
Accessibility
Performance
Responsiveness
<Navbar />
<div className="fixed top-0 w-full z-50">
<Navbar />
</div>
Hero
- Often used directly below the NavbarFooter
- Complementary navigation componentLayout
- Parent component that includes Navbar