ActiveNavLink
gr8monk3ys/active-nav-linkFreeComponent
Nav link with slide-in underline; sticks when the route is active.
Install it
npx shadcn@latest add https://ui.lscaturchio.xyz/r/active-nav-link.jsonSource
1"use client";23import type { ReactNode } from "react";45import Link from "next/link";6import { usePathname } from "next/navigation";78import { isPathActive } from "@/lib/navigation-path";9import { cn } from "@/lib/utils";1011interface ActiveNavLinkProps {12 href: string;13 children: ReactNode;14 className?: string;15 activeClassName?: string;16 inactiveClassName?: string;17}1819/** Nav link with the slide-in underline; underline sticks when active. */20export function ActiveNavLink({21 href,22 children,23 className,24 activeClassName,25 inactiveClassName,26}: ActiveNavLinkProps) {27 const pathname = usePathname();28 const active = isPathActive(pathname, href);2930 return (31 <Link32 href={href}33 aria-current={active ? "page" : undefined}34 className={cn(35 "nav-underline",36 active && "nav-underline-active",37 className,38 active ? activeClassName : inactiveClassName,39 )}40 >41 {children}42 </Link>43 );44}
What it pulls in
Other registry items
Files it writes
More from gr8monk3ys
All 69 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | gr8monk3ys | Components | Free | 2 deps | |
| alertalert | gr8monk3ys | Components | Free | 1 dep | |
| alert-dialogalert-dialog | gr8monk3ys | Components | Free | 1 dep | |
| aspect-ratioaspect-ratio | gr8monk3ys | Components | Free | 1 dep | |
| attachmentattachment | gr8monk3ys | Components | Free | 2 deps | |
| Avataravatar | gr8monk3ys | Components | Free | 1 dep | |
| Badgebadge | gr8monk3ys | Components | Free | 1 dep | |
| breadcrumbbreadcrumb | gr8monk3ys | Components | Free | 2 deps |
