-
So I'm trying to do a navigation menu, and highlighting the currently selected Nav Link(Matching current Path/Route). In NextJS(React) for example I use something like this: const NavItem = (props) => (
<Link href={props.path}>
<a className={`${ props.router.pathname === props.path ? "nav-selected" : "" } other-classes`}>
<div className="nav-icon">{props.icon}</div>
<span>{props.label}</span>
</a>
</Link>
); But currently there's no mention or example of how to do this in Solidjs, neither in the Main Docs or in the Solid-Router GitHub Page. Unless I'm missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I completely missed this note in the: Create Links to Your Routes section from
This is my Final import { NavLink } from "@solidjs/router";
const Nav = () => {
const Links = [
{
text: "Home",
route: "/",
},
{
text: "About",
route: "/about",
},
];
return (
<div>
{Links.map((link) => (
<NavLink class="nav-item" href={link.route} end>
{link.text}
</NavLink>
))}
</div>
);
};
export default Nav; |
Beta Was this translation helpful? Give feedback.
I completely missed this note in the: Create Links to Your Routes section from
solid-router
GitHub Documentation:This is my Final
Nav Component
code for those interested: