Bootstrap Vue Navs & Tabs Components

Documentation and examples for how to use Bootstrap Vue's included navigation components.

Base nav

Navigation available in Bootstrap Vue share general markup and styles, from the base .nav class to the active and disabled states. Swap modifier classes to switch between each style.

The base .nav component is built with flexbox and provide a strong foundation for building all types of navigation components. It includes some style overrides (for working with lists), some link padding for larger hit areas, and basic disabled styling.

<CNav>
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Classes are used throughout, so your markup can be super flexible. Use <ul>s like above, <ol> if the order of your items is important, or roll your own with a <nav> element. Because the .nav uses display: flex, the nav links behave the same as nav items would, but without the extra markup.


  <CNav component="nav">
    <CNavLink href="#" active>
      Active
    </CNavLink>
    <CNavLink href="#">Link</CNavLink>
    <CNavLink href="#">Link</CNavLink>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNav>

1
2
3
4
5
6
7
8
9
10
11
12

Available styles

Change the style of .navs component with modifiers and utilities. Mix and match as needed, or build your own.

Horizontal alignment

Change the horizontal alignment of your nav with flexbox utilitiesopen in new window. By default, navs are left-aligned, but you can easily change them to center or right aligned.

Centered with .justify-content-center:

<CNav class="justify-content-center">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Right-aligned with .justify-content-end:

<CNav class="justify-content-end">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Vertical

Stack your navigation by changing the flex item direction with the .flex-column utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., .flex-sm-column).

<CNav class="flex-column">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Tabs

Takes the basic nav from above and adds the variant="tabs" class to generate a tabbed interface

<CNav variant="tabs">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Pills

Take that same HTML, but use variant="pills" instead:

<CNav variant="pills">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Fill and justify

Force your .nav's contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your .nav-items, use layout="fill". Notice that all horizontal space is occupied, but not every nav item has the same width.

<CNav variant="pills" layout="fill">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

For equal-width elements, use layout="justified". All horizontal space will be occupied by nav links, but unlike the .nav-fill above, every nav item will be the same width.

<CNav variant="pills" layout="justified">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Working with flex utilities

If you need responsive nav variations, consider using a series of flexbox utilitiesopen in new window. While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.

<CNav component="nav" variant="pills" class="flex-column flex-sm-row">
  <CNavLink href="#" active>
    Active
  </CNavLink>
  <CNavLink href="#">Link</CNavLink>
  <CNavLink href="#">Link</CNavLink>
  <CNavLink href="#" disabled>
    Disabled
  </CNavLink>
</CNav>
1
2
3
4
5
6
7
8
9
10

Regarding accessibility

If you're using navs to provide a navigation bar, be sure to add a role="navigation" to the most logical parent container of the <ul>, or wrap a <nav> element around the whole navigation. Do not add the role to the <ul> itself, as this would prevent it from being announced as an actual list by assistive technologies.

Note that navigation bars, even if visually styled as tabs with the .nav-tabs class, should not be given role="tablist", role="tab" or role="tabpanel" attributes. These are only appropriate for dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practicesopen in new window. See JavaScript behavior for dynamic tabbed interfaces in this section for an example. The aria-current attribute is not necessary on dynamic tabbed interfaces since our JavaScript handles the selected state by adding aria-selected="true" on the active tab.

Using dropdowns

Add dropdown menus with a little extra HTML.

Tabs with dropdowns

<CNav>
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CDropdown variant="nav-item">
    <CDropdownToggle color="secondary">Dropdown button</CDropdownToggle>
    <CDropdownMenu>
      <CDropdownItem href="#">Action</CDropdownItem>
      <CDropdownItem href="#">Another action</CDropdownItem>
      <CDropdownItem href="#">Something else here</CDropdownItem>
    </CDropdownMenu>
  </CDropdown>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Pills with dropdowns

<CNav variant="pills">
  <CNavItem>
    <CNavLink href="#" active>
      Active
    </CNavLink>
  </CNavItem>
  <CDropdown variant="nav-item">
    <CDropdownToggle color="secondary">Dropdown button</CDropdownToggle>
    <CDropdownMenu>
      <CDropdownItem href="#">Action</CDropdownItem>
      <CDropdownItem href="#">Another action</CDropdownItem>
      <CDropdownItem href="#">Something else here</CDropdownItem>
    </CDropdownMenu>
  </CDropdown>
  <CNavItem>
    <CNavLink href="#">Link</CNavLink>
  </CNavItem>
  <CNavItem>
    <CNavLink href="#" disabled>
      Disabled
    </CNavLink>
  </CNavItem>
</CNav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Tab panes

Dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practicesopen in new window, require role="tablist", role="tab", role="tabpanel", and additional aria- attributes in order to convey their structure, functionality and current state to users of assistive technologies (such as screen readers).

Note that dynamic tabbed interfaces should not contain dropdown menus, as this causes both usability and accessibility issues. From a usability perspective, the fact that the currently displayed tab's trigger element is not immediately visible (as it's inside the closed dropdown menu) can cause confusion. From an accessibility point of view, there is currently no sensible way to map this sort of construct to a standard WAI ARIA pattern, meaning that it cannot be easily made understandable to users of assistive technologies.

Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
<template>
  <CNav variant="tabs" role="tablist">
    <CNavItem>
      <CNavLink
        href="javascript:void(0);"
        :active="tabPaneActiveKey === 1"
        @click="() => {tabPaneActiveKey = 1}"
      >
        Home
      </CNavLink>
    </CNavItem>
    <CNavItem>
      <CNavLink
        href="javascript:void(0);"
        :active="tabPaneActiveKey === 2"
        @click="() => {tabPaneActiveKey = 2}"
      >
        Profile
      </CNavLink>
    </CNavItem>
    <CNavItem>
      <CNavLink
        href="javascript:void(0);"
        :active="tabPaneActiveKey === 3"
        @click="() => {tabPaneActiveKey = 3}"
      >
        Contact
      </CNavLink>
    </CNavItem>
  </CNav>
  <CTabContent>
    <CTabPane role="tabpanel" aria-labelledby="home-tab" :visible="tabPaneActiveKey === 1">
      Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown
      aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan
      helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh
      mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan
      aliquip quis cardigan american apparel, butcher voluptate nisi qui.
    </CTabPane>
    <CTabPane role="tabpanel" aria-labelledby="profile-tab" :visible="tabPaneActiveKey === 2">
      Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid.
      Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan
      four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft
      beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic,
      assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero
      magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit,
      sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party
      scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
    </CTabPane>
    <CTabPane role="tabpanel" aria-labelledby="contact-tab" :visible="tabPaneActiveKey === 3">
      Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic
      lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork
      tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie
      helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork.
      Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro
      mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog
      stumptown. Pitchfork sustainable tofu synth chambray yr.
    </CTabPane>
  </CTabContent>
</template>
<script>
  export default {
    data() {
      return { 
        tabPaneActiveKey: 1,
      }
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

The tabs also works with pills.

Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
<template>
  <CNav variant="tabs" role="tablist">
    <CNavItem>
      <CNavLink
        href="javascript:void(0);"
        :active="tabPanePillsActiveKey === 1"
        @click="() => {tabPanePillsActiveKey = 1}"
      >
        Home
      </CNavLink>
    </CNavItem>
    <CNavItem>
      <CNavLink
        href="javascript:void(0);"
        :active="tabPanePillsActiveKey === 2"
        @click="() => {tabPanePillsActiveKey = 2}"
      >
        Profile
      </CNavLink>
    </CNavItem>
    <CNavItem>
      <CNavLink
        href="javascript:void(0);"
        :active="tabPanePillsActiveKey === 3"
        @click="() => {tabPanePillsActiveKey = 3}"
      >
        Contact
      </CNavLink>
    </CNavItem>
  </CNav>
  <CTabContent>
    <CTabPane role="tabpanel" aria-labelledby="home-tab" :visible="tabPanePillsActiveKey === 1">
      Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown
      aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan
      helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh
      mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan
      aliquip quis cardigan american apparel, butcher voluptate nisi qui.
    </CTabPane>
    <CTabPane role="tabpanel" aria-labelledby="profile-tab" :visible="tabPanePillsActiveKey === 2">
      Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid.
      Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan
      four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft
      beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic,
      assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero
      magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit,
      sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party
      scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
    </CTabPane>
    <CTabPane role="tabpanel" aria-labelledby="contact-tab" :visible="tabPanePillsActiveKey === 3">
      Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic
      lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork
      tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie
      helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork.
      Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro
      mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog
      stumptown. Pitchfork sustainable tofu synth chambray yr.
    </CTabPane>
  </CTabContent>
</template>
<script>
  export default {
    data() {
      return { 
        tabPanePillsActiveKey: 1,
      }
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

API

CNav

import { CNav } from '@coreui/bootstrap-vue'
// or
import CNav from '@coreui/bootstrap-vue/src/components/nav/CNav'
1
2
3

Props

Prop nameDescriptionTypeValuesDefault
componentComponent used for the root node. Either a string to use a HTML element or a component.string-'ul'
layoutSpecify a layout type for component.string'fill', 'justified'-
variantSet the nav variant to tabs or pills.string'tabs', 'pills'-

CNavGroup

import { CNavGroup } from '@coreui/bootstrap-vue'
// or
import CNavGroup from '@coreui/bootstrap-vue/src/components/nav/CNavGroup'
1
2
3

Props

Prop nameDescriptionTypeValuesDefault
compactMake nav group more compact by cutting all padding in half.boolean-
visibleShow nav group items.boolean-

Events

Event nameDescriptionProperties
visible-change

CNavItem

import { CNavItem } from '@coreui/bootstrap-vue'
// or
import CNavItem from '@coreui/bootstrap-vue/src/components/nav/CNavItem'
1
2
3

CNavItem and CNavLink have the same properties. If you set the href property on CNavItem then, CNavLink will be generated inside CNavItem.

import { CNavLink } from '@coreui/bootstrap-vue'
// or
import CNavLink from '@coreui/bootstrap-vue/src/components/nav/CNavLink'
1
2
3

Props

Prop nameDescriptionTypeValuesDefault
activeToggle the active state for the component.boolean-
componentComponent used for the root node. Either a string to use a HTML element or a component.string-'a'
disabledToggle the disabled state for the component.boolean-