Application Shell 14



<section id="relume">
<div
class="sticky top-0 z-40 flex w-full flex-wrap items-center justify-between border-b border-border-primary bg-background-primary px-6 lg:px-8"
>
<div class="flex min-h-16 items-center md:min-h-18">
<button class="-ml-4 mr-4 flex size-12 flex-col items-center justify-center lg:hidden">
<span class="my-[3px] h-0.5 w-6 bg-black"></span
><span class="my-[3px] h-0.5 w-6 bg-black"></span
><span class="my-[3px] h-0.5 w-6 bg-black"></span></button
><a href="#"
><img src="https://d22po4pjz3o32e.cloudfront.net/logo-image.svg" alt="Logo image"
/></a>
</div>
<div class="ml-auto flex flex-row items-center gap-4 lg:order-last">
<div class="hidden w-full max-w-md lg:block">
<div class="relative flex w-full items-center">
<div class="absolute left-3">
<svg
stroke="currentColor"
fill="currentColor"
stroke-width="0"
viewBox="0 0 24 24"
class="size-6"
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"
></path>
</svg>
</div>
<input
class="flex size-full min-h-11 border border-border-primary bg-background-primary py-2 align-middle file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-neutral focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 pl-[2.75rem] pr-3 w-full"
placeholder="Search"
/>
</div>
</div>
<div class="flex shrink-0 items-center gap-2 md:gap-4">
<button class="p-2 lg:hidden">
<svg
stroke="currentColor"
fill="currentColor"
stroke-width="0"
viewBox="0 0 24 24"
class="size-6"
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"
></path>
</svg></button
><button
type="button"
id="radix-:R79:"
aria-haspopup="menu"
aria-expanded="false"
data-state="closed"
class="cursor-pointer border border-border-alternative p-2 focus-visible:outline-none relative"
>
<div
class="absolute bottom-auto left-auto right-2 top-2 size-2 rounded-full bg-black outline outline-[3px] outline-offset-0 outline-white"
></div>
<svg
stroke="currentColor"
fill="currentColor"
stroke-width="0"
viewBox="0 0 24 24"
class="size-6"
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19 13.586V10c0-3.217-2.185-5.927-5.145-6.742C13.562 2.52 12.846 2 12 2s-1.562.52-1.855 1.258C7.185 4.074 5 6.783 5 10v3.586l-1.707 1.707A.996.996 0 0 0 3 16v2a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-2a.996.996 0 0 0-.293-.707L19 13.586zM19 17H5v-.586l1.707-1.707A.996.996 0 0 0 7 14v-4c0-2.757 2.243-5 5-5s5 2.243 5 5v4c0 .266.105.52.293.707L19 16.414V17zm-7 5a2.98 2.98 0 0 0 2.818-2H9.182A2.98 2.98 0 0 0 12 22z"
></path>
</svg></button
><button
type="button"
id="radix-:R99:"
aria-haspopup="menu"
aria-expanded="false"
data-state="closed"
class="cursor-pointer border border-border-alternative focus-visible:outline-none flex items-center p-0"
>
<img
src="https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg"
alt="Avatar"
class="size-10 rounded-full object-cover"
/>
</button>
</div>
</div>
<div
class="w-full overflow-hidden lg:order-2 lg:ml-6 lg:w-auto lg:grow lg:[--height-closed:auto] lg:[--height-open:auto]"
style="height: var(--height-closed, 0)"
>
<div class="pb-8 pt-4 lg:flex lg:items-center lg:py-0">
<a href="#" class="block py-3 lg:px-4 lg:py-2">Link One</a
><a href="#" class="block py-3 lg:px-4 lg:py-2">Link Two</a
><a href="#" class="block py-3 lg:px-4 lg:py-2">Link Three</a>
<div>
<button
class="flex w-full items-center justify-between gap-2 py-3 text-left lg:flex-none lg:justify-start lg:px-4 lg:py-2"
>
<span>Link Four</span
><span
><svg
stroke="currentColor"
fill="none"
stroke-width="0"
viewBox="0 0 15 15"
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z"
fill="currentColor"
></path></svg
></span>
</button>
</div>
</div>
</div>
</div>
<main class="relative flex min-h-screen flex-col lg:flex-row">
<div
class="static top-18 order-last flex flex-col lg:sticky lg:h-[calc(100vh-4.5rem)] lg:overflow-auto lg:border-l lg:border-[#d3d3d3]"
>
<div class="p-6 lg:p-8">
<div class="grid min-h-screen grid-cols-1 gap-12 sm:min-w-[22rem]">
<h1
class="flex h-screen items-center justify-center border-2 border-dashed border-[#d3d3d3] text-center text-black/50"
>
Click and paste Side Panel Content
</h1>
</div>
</div>
</div>
<div class="flex-1 bg-background-secondary">
<div class="border-b-2 border-dashed border-[#d3d3d3] py-6 text-center text-black/50">
<h1>Click and paste Page Header</h1>
</div>
<div class="container px-6 py-8 md:px-8 md:py-10 lg:py-12">
<div class="grid grid-cols-1 gap-12">
<div
class="flex h-screen items-center justify-center border-2 border-dashed border-[#d3d3d3] py-6 text-center text-black/50"
>
<h2>Click and paste Main Content</h2>
</div>
</div>
</div>
</div>
</main>
</section>
"use client";
import { useEffect, useRef, useState } from "react";
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
Input,
useMediaQuery,
} from "@relume_io/relume-ui";
import { AnimatePresence, motion } from "framer-motion";
import { RxChevronDown, RxChevronRight, RxCross2 } from "react-icons/rx";
import { BiBell, BiSearch } from "react-icons/bi";
type ImageProps = {
url?: string;
src: string;
alt?: string;
};
type NavLink = {
url: string;
title: string;
subMenuLinks?: NavLink[];
};
type Props = {
logo: ImageProps;
navLinks: NavLink[];
};
export type ApplicationShell14Props = React.ComponentPropsWithoutRef<"section"> & Partial<Props>;
export const ApplicationShell14 = (props: ApplicationShell14Props) => {
const { logo, navLinks } = {
...ApplicationShell14Defaults,
...props,
};
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const [isSearchIconClicked, setIsSearchIconClicked] = useState<boolean>(false);
const searchBarRef = useRef<HTMLDivElement>(null);
const menuRef = useRef<HTMLDivElement>(null);
const isMobile = useMediaQuery("(max-width: 991px)");
useEffect(() => {
if (!isSearchIconClicked) {
return;
}
const handleClickOutside = (event: PointerEvent) => {
if (searchBarRef.current && !searchBarRef.current.contains(event.target as Node)) {
setIsSearchIconClicked(false);
}
};
document.addEventListener("pointerdown", handleClickOutside);
return () => {
document.removeEventListener("pointerdown", handleClickOutside);
};
}, [isSearchIconClicked]);
useEffect(() => {
if (!menuRef) {
return;
}
const handleClickOutside = (event: PointerEvent) => {
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
setIsMobileMenuOpen(false);
}
};
document.addEventListener("pointerdown", handleClickOutside);
return () => {
document.removeEventListener("pointerdown", handleClickOutside);
};
}, [isSearchIconClicked]);
return (
<section id="relume">
<div className="sticky top-0 z-40 flex w-full flex-wrap items-center justify-between border-b border-border-primary bg-background-primary px-6 lg:px-8">
<div className="flex min-h-16 items-center md:min-h-18">
<button
className="-ml-4 mr-4 flex size-12 flex-col items-center justify-center lg:hidden"
onPointerDown={(e) => e.stopPropagation()}
onClick={() => {
setIsMobileMenuOpen(!isMobileMenuOpen);
setIsSearchIconClicked(false);
}}
>
<motion.span
className="my-[3px] h-0.5 w-6 bg-black"
animate={isMobileMenuOpen ? ["open", "rotatePhase"] : "closed"}
variants={topLineVariants}
/>
<motion.span
className="my-[3px] h-0.5 w-6 bg-black"
animate={isMobileMenuOpen ? "open" : "closed"}
variants={middleLineVariants}
/>
<motion.span
className="my-[3px] h-0.5 w-6 bg-black"
animate={isMobileMenuOpen ? ["open", "rotatePhase"] : "closed"}
variants={bottomLineVariants}
/>
</button>
<a href={logo.url}>
<img src={logo.src} alt={logo.alt} />
</a>
</div>
<div className="ml-auto flex flex-row items-center gap-4 lg:order-last">
<div className="hidden w-full max-w-md lg:block">
<Input className="w-full" placeholder="Search" icon={<BiSearch className="size-6" />} />
</div>
<div className="flex shrink-0 items-center gap-2 md:gap-4">
<button
onPointerDown={(e) => e.stopPropagation()}
onClick={() => {
setIsMobileMenuOpen(false);
setIsSearchIconClicked(!isSearchIconClicked);
}}
className="p-2 lg:hidden"
>
<BiSearch className="size-6" />
</button>
<AnimatePresence>
{isSearchIconClicked && (
<motion.div
ref={searchBarRef}
variants={{
visible: { opacity: 1 },
hidden: { opacity: 0 },
}}
initial="hidden"
exit="hidden"
animate={isSearchIconClicked ? "visible" : "hidden"}
className="absolute bottom-0 left-0 right-0 top-16 mt-px flex h-16 max-w-md items-center justify-center border-b border-border-primary bg-white px-6 lg:hidden"
>
<Input
className="h-fit w-full"
placeholder="Search"
icon={<BiSearch className="size-6" />}
/>
<button onClick={() => setIsSearchIconClicked(!isSearchIconClicked)}>
<RxCross2 className="ml-4 size-6" />
</button>
</motion.div>
)}
</AnimatePresence>
<DropdownMenu>
<DropdownMenuTrigger className="relative">
<div className="absolute bottom-auto left-auto right-2 top-2 size-2 rounded-full bg-black outline outline-[3px] outline-offset-0 outline-white" />
<BiBell className="size-6" />
</DropdownMenuTrigger>
<DropdownMenuContent className="max-w-[19rem] px-0" align="end" sideOffset={0}>
<div className="flex flex-col">
<div className="flex items-center justify-between px-4 py-2">
<DropdownMenuLabel className="p-0">Notifications</DropdownMenuLabel>
<a href="#">Mark as read</a>
</div>
<DropdownMenuSeparator />
<div className="h-full max-h-[14rem] overflow-auto px-2 py-1">
<DropdownMenuItem className="mt-2 grid grid-cols-[max-content_1fr] gap-2 px-2 py-1">
<div className="flex size-full flex-col items-start justify-start">
<img
src="https://d22po4pjz3o32e.cloudfront.net/relume-icon.svg"
alt="Avatar"
className="size-6"
/>
</div>
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p className="mt-2 text-sm">11 Jan 2022</p>
</div>
</DropdownMenuItem>
<DropdownMenuItem className="mt-2 grid grid-cols-[max-content_1fr] gap-2 px-2 py-1">
<div className="flex size-full flex-col items-start justify-start">
<img
src="https://d22po4pjz3o32e.cloudfront.net/relume-icon.svg"
alt="Avatar"
className="size-6"
/>
</div>
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p className="mt-2 text-sm">11 Jan 2022</p>
</div>
</DropdownMenuItem>
</div>
</div>
<DropdownMenuSeparator />
<div className="flex w-full items-end justify-end px-4 py-2">
<Button variant="link" size="link" iconRight={<RxChevronRight />} asChild>
<a href="#">View All</a>
</Button>
</div>
</DropdownMenuContent>
</DropdownMenu>
<DropdownMenu>
<DropdownMenuTrigger className="flex items-center p-0">
<img
src="https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg"
alt="Avatar"
className="size-10 rounded-full object-cover"
/>
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
sideOffset={0}
className="mt-1.5 min-w-32 px-0 py-2 md:min-w-48"
>
<DropdownMenuGroup>
<DropdownMenuItem>
<a href="#">My Profile</a>
</DropdownMenuItem>
<DropdownMenuItem>
<a href="#">Profile Settings</a>
</DropdownMenuItem>
<DropdownMenuSeparator className="mx-4" />
<DropdownMenuItem>
<a href="#">Log Out</a>
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
<motion.div
ref={menuRef}
variants={{
open: {
height: "var(--height-open, auto)",
},
close: {
height: "var(--height-closed, 0)",
},
}}
initial="close"
exit="close"
animate={isMobileMenuOpen ? "open" : "close"}
transition={{ duration: 0.4 }}
className="w-full overflow-hidden lg:order-2 lg:ml-6 lg:w-auto lg:grow lg:[--height-closed:auto] lg:[--height-open:auto]"
>
<div className="pb-8 pt-4 lg:flex lg:items-center lg:py-0">
{navLinks.map((navLink, index) =>
navLink.subMenuLinks && navLink.subMenuLinks.length > 0 ? (
<SubMenu key={index} navLink={navLink} isMobile={isMobile} />
) : (
<a key={index} href={navLink.url} className="block py-3 lg:px-4 lg:py-2">
{navLink.title}
</a>
),
)}
</div>
</motion.div>
</div>
<main className="relative flex min-h-screen flex-col lg:flex-row">
<div className="static top-18 order-last flex flex-col lg:sticky lg:h-[calc(100vh-4.5rem)] lg:overflow-auto lg:border-l lg:border-[#d3d3d3]">
<div className="p-6 lg:p-8">
<div className="grid min-h-screen grid-cols-1 gap-12 sm:min-w-[22rem]">
<h1 className="flex h-screen items-center justify-center border-2 border-dashed border-[#d3d3d3] text-center text-black/50">
Click and paste Side Panel Content
</h1>
</div>
</div>
</div>
<div className="flex-1 bg-background-secondary">
<div className="border-b-2 border-dashed border-[#d3d3d3] py-6 text-center text-black/50">
<h1>Click and paste Page Header</h1>
</div>
<div className="container px-6 py-8 md:px-8 md:py-10 lg:py-12">
<div className="grid grid-cols-1 gap-12">
<div className="flex h-screen items-center justify-center border-2 border-dashed border-[#d3d3d3] py-6 text-center text-black/50">
<h2>Click and paste Main Content</h2>
</div>
</div>
</div>
</div>
</main>
</section>
);
};
const SubMenu = ({ navLink, isMobile }: { navLink: NavLink; isMobile: boolean }) => {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
return (
<div
onMouseEnter={() => !isMobile && setIsDropdownOpen(true)}
onMouseLeave={() => !isMobile && setIsDropdownOpen(false)}
>
<button
className="flex w-full items-center justify-between gap-2 py-3 text-left lg:flex-none lg:justify-start lg:px-4 lg:py-2"
onClick={() => setIsDropdownOpen((prev) => !prev)}
>
<span>{navLink.title}</span>
<motion.span
variants={{
rotated: { rotate: 180 },
initial: { rotate: 0 },
}}
animate={isDropdownOpen ? "rotated" : "initial"}
transition={{ duration: 0.3 }}
>
<RxChevronDown />
</motion.span>
</button>
{isDropdownOpen && (
<AnimatePresence>
<motion.nav
variants={{
open: {
visibility: "visible",
opacity: "var(--opacity-open, 100%)",
y: 0,
},
close: {
visibility: "hidden",
opacity: "var(--opacity-close, 0)",
y: "var(--y-close, 0%)",
},
}}
animate={isDropdownOpen ? "open" : "close"}
initial="close"
exit="close"
transition={{ duration: 0.2 }}
className="bg-background-primary lg:absolute lg:z-50 lg:border lg:border-border-primary lg:p-2 lg:[--y-close:25%]"
>
{navLink.subMenuLinks?.map((navLink, index) => (
<a key={index} href={navLink.url} className="block px-4 py-2">
{navLink.title}
</a>
))}
</motion.nav>
</AnimatePresence>
)}
</div>
);
};
export const ApplicationShell14Defaults: Props = {
logo: {
url: "#",
src: "https://d22po4pjz3o32e.cloudfront.net/logo-image.svg",
alt: "Logo image",
},
navLinks: [
{ title: "Link One", url: "#" },
{ title: "Link Two", url: "#" },
{ title: "Link Three", url: "#" },
{
title: "Link Four",
url: "#",
subMenuLinks: [
{ title: "Link Five", url: "#" },
{ title: "Link Six", url: "#" },
{ title: "Link Seven", url: "#" },
],
},
],
};
const topLineVariants = {
open: {
translateY: 8,
transition: { delay: 0.1 },
},
rotatePhase: {
rotate: -45,
transition: { delay: 0.2 },
},
closed: {
translateY: 0,
rotate: 0,
transition: { duration: 0.2 },
},
};
const middleLineVariants = {
open: {
width: 0,
transition: { duration: 0.1 },
},
closed: {
width: "1.5rem",
transition: { delay: 0.3, duration: 0.2 },
},
};
const bottomLineVariants = {
open: {
translateY: -8,
transition: { delay: 0.1 },
},
rotatePhase: {
rotate: 45,
transition: { delay: 0.2 },
},
closed: {
translateY: 0,
rotate: 0,
transition: { duration: 0.2 },
},
};
Need help?
For installation guidelines and API information, visit the docs.
Examples
No items found.