Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap nav pills for VueJS vue-router

In the bootstrap official docs I have seen a cool nav pills set. This is it.

<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
  <a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a>
  <a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a>
  <a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</a>
  <a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a>
</div>
<div class="tab-content" id="v-pills-tabContent">
  <div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">...</div>
  <div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
  <div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
  <div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>

and this is the code I currently using for navigation.

<ul class="nav flex-column">
          <li class="nav-item">
            <router-link to="/studentDashboard">Dashboard</router-link>
          </li>

          <li class="nav-item">
            <router-link to="/buyPapers">Buy papers</router-link>
          </li>

          <li class="nav-item" >
            <router-link to="/myPapers">My papers</router-link>
          </li>

  </ul>

What should I change to use that pills in this code?

like image 290
Pathum Kalhan Avatar asked Apr 03 '18 08:04

Pathum Kalhan


1 Answers

<router-link> by defult is rendered as an achor tag `<a>`.

Bootstap 4 nav-pills have a <a> tag with class nav-link. as below:

<ul class="nav nav-pills">
  <li class="nav-item">
    <a class="nav-link active" href="#">Active</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" href="#">Link</a>
  </li>
  </li>
</ul>

So just add that class to your <router-link>

<li class="nav-item">
  <router-link class="nav-link" active-class="active" to="/studentDashboard">Dashboard</router-link>
</li>

To add the active class to the nav-pill that represents the current active route add active-class prop on every `

like image 109
Vamsi Krishna Avatar answered Sep 20 '22 15:09

Vamsi Krishna