Navbar 31
NavbarsLogo LeftMenu RightMega MenuNavbar

Code
relume-navbar31.tsx
"use client";
import { useState } from "react";
import { motion } from "motion/react";
import { Button, type ButtonProps } from "@/components/ui/button";
import { Sheet, SheetClose, SheetContent, SheetTrigger } from "@/components/ui/sheet";
import { FacebookLogo, InstagramLogo, LinkedinLogo, YoutubeLogo, XLogo } from "relume-icons";
type ImageProps = {
url?: string;
src: string;
alt?: string;
};
type SocialMediaLink = {
url: string;
icon: React.ReactNode;
};
type NavLink = {
url: string;
title: string;
subMenuLinks?: NavLink[];
};
type NavBottom = {
socialMediaLinks: SocialMediaLink[];
button: ButtonProps & {
url: string;
};
contactInfo: {
phone?: string;
email?: string;
address?: string;
title?: string;
};
};
type Props = {
logo: ImageProps;
navLinks: NavLink[];
button: ButtonProps;
navBottom: NavBottom;
};
export type Navbar31Props = React.ComponentPropsWithoutRef<"section"> & Partial<Props>;
export const Navbar31 = (props: Navbar31Props) => {
const { logo, navLinks, button, navBottom } = {
...Navbar31Defaults,
...props,
};
const [isMenuOpen, setIsMenuOpen] = useState(false);
return (
<section className="relative z-[999] flex min-h-16 w-full items-center bg-scheme-background px-[5%] md:min-h-18">
<div className="mx-auto flex size-full items-center justify-between">
<a href={logo.url}>
<img src={logo.src} alt={logo.alt} />
</a>
<div className="flex items-center justify-center gap-3">
<Button {...button} className="px-4 py-1 md:px-6 md:py-2">
{button.title}
</Button>
<Sheet open={isMenuOpen} onOpenChange={setIsMenuOpen}>
<SheetTrigger className="flex size-12 flex-col items-center justify-center">
<HamburgerIcon isMenuOpen={isMenuOpen} />
</SheetTrigger>
<SheetContent
side="right"
className="w-full max-w-[90%] border-l border-scheme-border bg-scheme-background px-[5%] pb-12 md:max-w-[40%] md:px-[5%] lg:max-w-[26rem] lg:px-[5%] lg:pt-18 lg:pb-12"
>
<SheetClose className="absolute top-0 right-0 min-h-18 px-[5vw]">
<HamburgerIcon isMenuOpen={isMenuOpen} />
</SheetClose>
<div className="flex h-full flex-col justify-between overflow-auto">
<div className="grid grid-cols-1 py-8">
{navLinks.map((navLink, index) => (
<a
key={index}
href={navLink.url}
className="py-2 text-h3 leading-[1.2] font-bold"
>
{navLink.title}
</a>
))}
</div>
<div>
<p className="mb-2 font-semibold">{navBottom.contactInfo.title}</p>
<p className="mb-1 text-small underline">{navBottom.contactInfo.phone}</p>
<p className="mb-1 text-small underline">{navBottom.contactInfo.email}</p>
<p className="text-small">{navBottom.contactInfo.address}</p>
<div className="mt-6 flex items-center gap-3 md:mt-8">
{navBottom.socialMediaLinks.map((link, index) => (
<a key={index} href={link.url}>
{link.icon}
</a>
))}
</div>
</div>
</div>
</SheetContent>
</Sheet>
</div>
</div>
</section>
);
};
const HamburgerIcon = ({ isMenuOpen }: { isMenuOpen: boolean }) => {
const topLineVariants = {
open: {
width: 0,
transition: { duration: 0.1, ease: "easeIn" },
},
close: {
width: "100%",
transition: { duration: 0.1, delay: 0.4, ease: "linear" },
},
};
const middleLineVariants = {
open: {
rotate: 135,
transition: { duration: 0.3, delay: 0.4, ease: "easeInOut" },
},
close: {
rotate: 0,
transition: { duration: 0.3, ease: "easeInOut" },
},
openSecond: {
rotate: 45,
transition: { duration: 0.3, delay: 0.4, ease: "easeInOut" },
},
closeSecond: {
rotate: 0,
transition: { duration: 0.3, ease: "easeInOut" },
},
};
const bottomLineVariants = {
open: {
width: 0,
transition: { duration: 0.1, ease: "easeIn" },
},
close: {
width: "100%",
transition: { duration: 0.1, delay: 0.4, ease: "linear" },
},
};
return (
<span className="relative flex size-6 flex-col items-center justify-center">
<motion.span
className="absolute top-[3px] h-0.5 w-full bg-neutral-darkest"
animate={isMenuOpen ? "open" : "close"}
variants={topLineVariants}
/>
<motion.span
className="absolute h-0.5 w-full bg-neutral-darkest"
animate={isMenuOpen ? "open" : "close"}
variants={middleLineVariants}
/>
<motion.span
className="absolute h-0.5 w-full bg-neutral-darkest"
animate={isMenuOpen ? "openSecond" : "closeSecond"}
variants={middleLineVariants}
/>
<motion.span
className="absolute bottom-[3px] h-0.5 w-full bg-neutral-darkest"
animate={isMenuOpen ? "open" : "close"}
variants={bottomLineVariants}
/>
</span>
);
};
export const Navbar31Defaults: Props = {
logo: {
url: "#",
src: "https://d22po4pjz3o32e.cloudfront.net/logo-image.svg",
alt: "Relume placeholder logo",
},
navLinks: [
{
url: "#",
title: "Link One",
},
{
url: "#",
title: "Link Two",
},
{
url: "#",
title: "Link Three",
},
{
url: "#",
title: "Link Four",
},
{
url: "#",
title: "Link Five",
},
],
navBottom: {
button: { title: "Contact", variant: "link", size: "link", url: "#" },
socialMediaLinks: [
{ url: "#", icon: <FacebookLogo className="size-6 text-scheme-text" /> },
{ url: "#", icon: <InstagramLogo className="size-6 text-scheme-text" /> },
{ url: "#", icon: <XLogo className="size-6 text-scheme-text" /> },
{ url: "#", icon: <LinkedinLogo className="size-6 text-scheme-text" /> },
{ url: "#", icon: <YoutubeLogo className="size-6 text-scheme-text" /> },
],
contactInfo: {
phone: "1800 123 4567",
email: "email@example.com",
address: "Level 1, 12 Sample St, Sydney NSW 2000",
title: "Get in touch",
},
},
button: {
title: "Button",
size: "sm",
},
};npm i @radix-ui/react-accordion @radix-ui/react-dialog @radix-ui/react-slot @radix-ui/react-tabs class-variance-authority@0.7.1 clsx@^2.1.1 embla-carousel-react@^8.5.2 motion@^12.15.0 relume-icons@1.3.0 tailwind-merge@^2.2.2


