question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navbar always sets root page as "active"

See original GitHub issue

The 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:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
emanuelmutschlechnercommented, Apr 26, 2018

You have to set the exact prop:

https://bootstrap-vue.js.org/docs/components/link

2reactions
emanuelmutschlechnercommented, Apr 26, 2018

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found