mirror of
https://github.com/cosscom/coss.git
synced 2026-09-14 20:06:50 +08:00
38 lines
856 B
TypeScript
38 lines
856 B
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { usePathname } from "next/navigation";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
import { Button } from "@/registry/default/ui/button";
|
|
|
|
export function MainNav({
|
|
items,
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"nav"> & {
|
|
items: { href: string; label: string }[];
|
|
}) {
|
|
const pathname = usePathname();
|
|
|
|
return (
|
|
<nav className={cn("items-center gap-2", className)} {...props}>
|
|
{items.map((item) => (
|
|
<Button
|
|
data-pressed={pathname.includes(item.href) || undefined}
|
|
key={item.href}
|
|
render={
|
|
<Link
|
|
className={cn(pathname.includes(item.href) && "text-primary")}
|
|
href={item.href}
|
|
/>
|
|
}
|
|
variant="ghost"
|
|
>
|
|
{item.label}
|
|
</Button>
|
|
))}
|
|
</nav>
|
|
);
|
|
}
|