Skip to content

This next-js-active-link package this very simple. Here need just import NavLink and use it Like default <Link> component in next js. But this package have Active feature just need to add props "activeClassName"

Notifications You must be signed in to change notification settings

AbtahiHasan/next-js-active-route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next Js Active NavLink Link

Demo

Demo

Authors

Documentation

Documentation

Installation

install with npm

npm i next-js-active-route

install with yarn

yarn add next-js-active-route

install with pnpm

pnpm install next-js-active-route

Usage/Examples

import { NavLink } from "next-js-active-route";

const Demo = () => {
  return (
    <>
      <ul>
        <li>
          <NavLink
            href="/"
            exact={true}
            activeClassName="bg-green-600"
            className="border"
          >
            Home
          </NavLink>
          <NavLink
            href="/blogs"
            activeClassName="bg-green-600"
            className="border"
          >
            Blogs
          </NavLink>
        </li>
      </ul>
    </>
  );
};

export default Demo;

Props

Props Type Description
href string Required it's url page url
activeClassName string Required this all classes applied when your route is active
children ReactNode Required for example

Blog

className string Optional you can use any classNames
exact boolean Optional if you want to exact match for example your path is ('/')
*** any Optional that accept component

About

This next-js-active-link package this very simple. Here need just import NavLink and use it Like default <Link> component in next js. But this package have Active feature just need to add props "activeClassName"

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published