Navbar always sets root page as "active"
See original GitHub issueThe navbar sets active
class on the <a>
element based on the page the user selected, which is great. Unfortunately if one of my <b-nav-item>
components links to root (/
), root will always have the active class attached to it as well. Here is the code with which I am experiencing this:
<header>
<b-navbar toggleable="md" fixed="top" variant="white">
<b-navbar-brand to="/"><img src="/static/my-logo.svg" alt="logo"/></b-navbar-brand>
<b-navbar-toggle target="nav_collapse"></b-navbar-toggle>
<b-collapse is-nav id="nav_collapse" >
<b-navbar-nav>
<b-nav-item to="/">Home</b-nav-item>
<b-nav-item to="/page1">Page1</b-nav-item>
<b-nav-item to="/page2">Page2</b-nav-item>
<b-nav-item to="/page3">Page3</b-nav-item>
<b-nav-item to="/page4">Page4</b-nav-item>
</b-navbar-nav>
</b-collapse>
</b-navbar>
</header>
If I navigate to /page3
, both /page3
and /
will have the active
class attached to the anchor element.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
how do i set navbar item to be active by default before the user ...
I would like to have the Home nav-link stay active until the user clicks another nav-link to another part of the page (im...
Read more >Navbar · Bootstrap v5.0
Documentation and examples for Bootstrap's powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, ...
Read more >How To Create a Bottom Navigation Menu - W3Schools
Learn how to create a bottom navigation menu with CSS. ... Place the navbar at the bottom of the page, and make it...
Read more >Angular Navbar with Bootstrap - examples & tutorial
Active states—with .active —to indicate the current page can be applied directly to .nav-link s or their immediate parent .nav-item s.
Read more >Simple React Router Nav Bar - Karen Ying
Using React Router and clever CSS to create a nav bar with dots to show hover and active state.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have to set the
exact
prop:https://bootstrap-vue.js.org/docs/components/link
@mikeovc links in BootstrapVue are build upon Vue router links, e.g. the link
'/'
will be active for every url;'/help'
will be active for'/help'
,'/help/'
and'/help/*'
.https://router.vuejs.org/en/api/router-link.html
https://bootstrap-vue.js.org/docs/reference/router-links#common-router-link-props