NavLink active ClassName using styled-components
Rom858
Posted on June 29, 2021
npm i styled-components react-router-dom
or
yarn add styled-components react-router-dom
slyled-navlink.js
import styled from "styled-components"
export const StyledNavLink=styled(NavLink).attrs({activeClassName:"anyClassName"})`
color: black;
&.anyClassName{
color: red;
}
`;
*Note activeClassName accept string as className when NavLink is active so you can pass any className you like
💖 💪 🙅 🚩
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.