Skip to content

Commit 7997a05

Browse files
authored
Merge pull request #533 from s2sharpit/activePage
feat: Adding active page indicator in Navbar
2 parents e8f3bfe + cf27ca4 commit 7997a05

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/main-nav.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { cn } from "@/lib/utils";
66
import { NavItem } from "@/types/nav";
77
import Image from "next/image";
88
import Link from "next/link";
9+
import { usePathname } from 'next/navigation';
910
import { useEffect, useRef, useState } from "react";
1011
import { BiMenuAltRight } from "react-icons/bi";
1112
import { MdOutlineClose } from "react-icons/md";
@@ -19,6 +20,7 @@ interface MainNavProps {
1920
export function MainNav({ items }: MainNavProps) {
2021
const [toggle, setToggle] = useState<boolean>(false);
2122
const menuRef = useRef<HTMLDivElement>(null);
23+
const pathname = usePathname();
2224

2325
useEffect(() => {
2426
if (!toggle) return;
@@ -77,7 +79,8 @@ export function MainNav({ items }: MainNavProps) {
7779
href={item.href}
7880
className={cn(
7981
"flex items-center whitespace-nowrap text-xl font-semibold sm:text-sm",
80-
item.disabled && "cursor-not-allowed opacity-80"
82+
item.disabled && "cursor-not-allowed opacity-80",
83+
(item.href === pathname) && "text-purple-600"
8184
)}
8285
>
8386
{item.title}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy