Use 'active' state from React Router in Styled Components

前端 未结 9 1639
北海茫月
北海茫月 2021-02-15 12:24

React Router adds an active class to NavLinks when you are on the page that they link to. How can I access this property with Styled Components. I need to styled me

9条回答
  •  礼貌的吻别
    2021-02-15 12:56

    react-router now has activeStyle props, which can be used to style active link easily:

    
      FAQs
    
    

    With styled-components:

    const LinkElem = styled(NavLink)`
      font-size: 16px;
      font-weight: 400;
    `;
    
    ;
    

提交回复
热议问题