NavLink active ClassName using styled-components

rom858

Rom858

Posted on June 29, 2021

NavLink active ClassName using styled-components
npm i styled-components react-router-dom
or
yarn add styled-components react-router-dom
Enter fullscreen mode Exit fullscreen mode

slyled-navlink.js


import styled from "styled-components"


export const StyledNavLink=styled(NavLink).attrs({activeClassName:"anyClassName"})`
color: black;
&.anyClassName{
color: red;
}
`;
Enter fullscreen mode Exit fullscreen mode

*Note activeClassName accept string as className when NavLink is active so you can pass any className you like

💖 💪 🙅 🚩
rom858
Rom858

Posted on June 29, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What was your win this week?
weeklyretro What was your win this week?

November 29, 2024

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024

How to Use KitOps with MLflow
beginners How to Use KitOps with MLflow

November 29, 2024

Modern C++ for LeetCode 🧑‍💻🚀
leetcode Modern C++ for LeetCode 🧑‍💻🚀

November 29, 2024