Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 style(main-nav.tsx): Using usePathname from next/navigation to show user current page. #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kodbilenadam
Copy link

Today when I started using next-template (which is incredible and a great project!) I realized that while there is an option for disabled links in nav-items there is no option to show users the active page they are on.

If the menu item is disabled it won't show the current directory they are active but if the menu item is not disabled it's updating CSS to text-primary to show users the active page they are on.

The usePathname hook from next/navigation is now used to get the current pathname. If the current pathname matches the href of the current nav item, an active class is added to the link. This improves the user experience by providing visual feedback on the current page.
… is not disabled

The Link component was receiving a pathname prop regardless of whether the item was disabled or not. This caused the Link to be rendered with a pathname even when it was not clickable. Now, the pathname prop is only added to the Link component if the item is not disabled, ensuring that the Link is only clickable when it should be.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant