Skip to content

Get current path, selected Nav Link #148

Answered by NovusOpus
NovusOpus asked this question in Q&A
Discussion options

You must be logged in to vote

I completely missed this note in the: Create Links to Your Routes section from solid-router GitHub Documentation:

"If you use NavLink instead of Link, the anchor tag will have an active class if its href matches the current location, and inactive otherwise. Note: By default matching includes locations that are descendents (eg. href /users matches locations /users and /users/123), use the boolean end prop to prevent matching these. This is particularly useful for links to the root route / which would match everything."

This is my Final Nav Component code for those interested:

import { NavLink } from "@solidjs/router";

const Nav = () => {
  const Links = [
    {
      text: "Home",
      r…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by NovusOpus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant