Components
Loading preview...
An 8-bit styled navigation menu with pixel-border dropdown panels. Pure React state-based implementation with no Radix dependency — trigger, content, list, item, link, indicator and viewport subcomponents.
@reapollo
npx shadcn@latest add https://21st.dev/r/larsen66/8bit-navigation-menu"use client";
import * as React from "react";
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuIndicator,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
navigationMenuTriggerStyle,
} from "@/components/ui/8bit-navigation-menu";
const components: { title: string; href: string; description: string }[] = [
{
title: "Alert Dialog",
href: "/docs/components/alert-dialog",
description:
"A modal dialog that interrupts the user with important content and expects a response.",
},
{
title: "Hover Card",
href: "/docs/components/hover-card",
description:
"For sighted users to preview content available behind a link.",
},
{
title: "Progress",
href: "/docs/components/progress",
description:
"Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.",
},
{
title: "Scroll-area",
href: "/docs/components/scroll-area",
description:
"Augments native scroll functionality for custom, cross-browser styling.",
},
{
title: "Tabs",
href: "/docs/components/tabs",
description:
"A set of layered sections of content—known as tab panels—that are displayed one at a time.",
},
{
title: "Tooltip",
href: "/docs/components/tooltip",
description:
"A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.",
},
];
export default function NavigationMenuDemo() {
return (
<div className="flex min-h-[300px] items-start justify-center p-8 retro">
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger>Getting started</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid gap-2 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<li className="row-span-3">
<NavigationMenuLink asChild>
<a
className="flex h-full w-full select-none flex-col justify-end rounded-md bg-linear-to-b from-muted/50 to-muted p-6 no-underline outline-hidden focus:shadow-md"
href="/"
>
<div className="mt-4 mb-2 font-medium text-lg">
8bitcn/ui
</div>
<p className="text-muted-foreground text-sm leading-tight">
Beautifully designed components built with Tailwind CSS.
</p>
</a>
</NavigationMenuLink>
</li>
<ListItem href="/docs" title="Installation">
How to install dependencies and structure your app.
</ListItem>
<ListItem href="/docs/components/accordion" title="Components">
Re-usable components built using Radix UI and Tailwind CSS.
</ListItem>
<ListItem href="/blocks/authentication" title="Building Blocks">
Building Retro Blocks for the Web
</ListItem>
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuTrigger>Components</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid w-[400px] gap-2 md:w-[500px] md:grid-cols-2 lg:w-[600px]">
{components.map((component) => (
<ListItem
href={component.href}
key={component.title}
title={component.title}
>
{component.description}
</ListItem>
))}
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink asChild className={navigationMenuTriggerStyle()}>
<a href="/docs">Documentation</a>
</NavigationMenuLink>
</NavigationMenuItem>
<NavigationMenuIndicator />
</NavigationMenuList>
</NavigationMenu>
</div>
);
}
function ListItem({
title,
children,
href,
...props
}: React.ComponentPropsWithoutRef<"li"> & { href: string }) {
return (
<li {...props}>
<NavigationMenuLink asChild>
<a href={href}>
<div className="font-medium text-sm leading-none">{title}</div>
<p className="line-clamp-2 text-muted-foreground text-sm leading-snug">
{children}
</p>
</a>
</NavigationMenuLink>
</li>
);
}