This repository was archived by the owner on Jul 28, 2025. It is now read-only.
🎨 style(main-nav.tsx): Using usePathname from next/navigation to show user current page.#6
Open
kodbilenadam wants to merge 2 commits intoshadcn-ui:mainfrom
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.