Navs

Navigation available in Bootstrap share general markup and styles, from the base <b-nav> class to the active and disabled states. Swap modifier props to switch between each style.

<div>
  <b-nav>
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Another Link</b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav.vue -->

Overview

The base <b-nav> component is built with flexbox and provides 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. No active states are included in the base nav.

Two style variations are supported: tabs and pills, which support active state styling. These variants are mutually exclusive - use only one style or the other.

Tab style

Make the nav look like tabs by setting the tabs prop.

<div>
  <b-nav tabs>
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Another Link</b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav-tabs.vue -->

Pill style

Use the pill style by setting the pills prop.

<div>
  <b-nav pills>
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Another Link</b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav-pills.vue -->

Small

Make the nav smaller by setting the small prop.

<div>
  <b-nav small>
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Another Link</b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav-small.vue -->

Fill and justify

NEW in 2.0.0-rc19

Force your <b-nav> content to extend the full available width.

Fill

To proportionately fill all available space with your <b-nav-item> components, set the fill prop. Notice that all horizontal space is occupied, but not every nav item has the same width.

<div>
  <b-nav tabs fill>
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Link with a long name </b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav-fill.vue -->

Justified

For equal-width elements, set the justified prop instead. All horizontal space will be occupied by nav links, but unlike fill above, every <b-nav-item> will be the same width.

<div>
  <b-nav tabs justified>
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Link with a long name </b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav-justified.vue -->

Alignment

NEW in 2.0.0-rc19

To align your <b-nav-item> components, use the align prop. Available values are left, center and right.

<div>
  <b-nav tabs align="center">
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Link with a long name </b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav-alignment.vue -->

Vertical variation

By default <b-nav> appear on a horizontal line. Stack your navigation by setting the vertical prop.

<div>
  <b-nav vertical class="w-25">
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item>Another Link</b-nav-item>
    <b-nav-item disabled>Disabled</b-nav-item>
  </b-nav>
</div>

<!-- b-nav-vertical.vue -->

Use <b-nav-item-dropdown> to place dropdown items within your nav.

<div>
  <b-nav pills>
    <b-nav-item active>Active</b-nav-item>
    <b-nav-item>Link</b-nav-item>
    <b-nav-item-dropdown
      id="my-nav-dropdown"
      text="Dropdown"
      toggle-class="nav-link-custom"
      right
    >
      <b-dropdown-item>one</b-dropdown-item>
      <b-dropdown-item>two</b-dropdown-item>
      <b-dropdown-divider></b-dropdown-divider>
      <b-dropdown-item>three</b-dropdown-item>
    </b-nav-item-dropdown>
  </b-nav>
</div>

<!-- b-nav-dropdown.vue -->

Sometimes you want to add your own class names to the generated dropdown toggle button, that by default have the classes nav-link and dropdown-toggle. Use the toggle-class prop to add them (like above) which will produce something like:

<li id="my-nav-dropdown" class="nav-item b-nav-dropdown dropdown">
  <a
    href="#"
    id="my-nav-dropdown__BV_button_"
    aria-haspopup="true"
    aria-expanded="false"
    class="nav-link dropdown-toggle nav-link-custom"
  ></a>
  ...
</li>

Refer to <b-dropdown> for a list of supported sub-components.

Optionally scoped default slot

NEW in 2.0.0-rc.20

The dropdown default slot is optionally scoped with the following scope available:

Property or Method Description
hide() Can be used to close the dropdown menu. Accepts an optional boolean argument, which if true returns focus to the toggle button

Using in navbar

Prop is-nav-bar has been deprecated and will be removed in a future release.

Tabbed local content support

See the <b-tabs> component for creating tabbable panes of local content (not suited for navigation).

Accessibility

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

When using a <b-nav-item-dropdown> in your <b-nav>, be sure to assign a unique id prop value to the <b-nav-dropdown> so that the appropriate aria-* attributes can be automatically generated.

See also

  • <b-tabs> to create tabbable panes of local content, even via dropdown menus.
  • <b-navbar> a wrapper that positions branding, navigation, and other elements in a concise header.
  • <b-dropdown> for sub-components that you can place inside <b-nav-item-dropdown>
  • Router Link Support reference for information about router-link specific props available on <b-nav-item>

Component reference

Properties

PropertyTypeDefault Value
tag Stringul
fill Booleanfalse
justified Booleanfalse
align String
tabs Booleanfalse
pills Booleanfalse
vertical Booleanfalse
small Booleanfalse
is-nav-bar DeprecatedBooleanfalse

Setting prop "is-nav-bar" is deprecated. Use the <b-navbar-nav> component instead.

Properties

PropertyTypeDefault Value
href String
rel String
target String_self
active Booleanfalse
disabled Booleanfalse
to String or Object
append Booleanfalse
replace Booleanfalse
event String or Arrayclick
active-class String
exact Booleanfalse
exact-active-class String
router-tag Stringa
no-prefetch Booleanfalse
link-attrs Object{}
link-classes String or Object or Array

Properties

PropertyTypeDefault Value
tag Stringspan

Properties

PropertyTypeDefault Value
id String
novalidate Booleanfalse
validated Booleanfalse

<b-nav-item-dropdown>

Component aliases

<b-nav-item-dropdown> can also be used via the following aliases:

  • <b-nav-item-dd>
  • <b-nav-dropdown>
  • <b-nav-dd>

Note: component aliases are only available when importing all of BootstrapVue or using the component group plugin.

Properties

PropertyTypeDefault Value
id String
disabled Booleanfalse
text String
html String
dropup Booleanfalse
dropright Booleanfalse
dropleft Booleanfalse
right Booleanfalse
offset Number or String0
no-flip Booleanfalse
popper-opts Object
menu-class String or Array
toggle-class String or Array
no-caret Booleanfalse
role Stringmenu
extra-menu-classes DeprecatedString

Setting prop "extra-menu-classes" is deprecated. Use "menu-class" prop instead.

extra-toggle-classes DeprecatedString

Setting prop "extra-toggle-classes" is deprecated. Use "toggle-class" prop instead.

Slots

SlotDescription
button-contentCan be used to implement custom text with icons and more styling.

Events

EventArgumentsDescription
show
bvEvt - BvEvent object. Call bvEvt.preventDefault() to cancel show.
Emitted just before dropdown is shown. Cancelable.
shownEmitted when dropdown is shown.
hide
bvEvt - BvEvent object. Call bvEvt.preventDefault() to cancel hide.
Emitted just before dropdown is hidden. Cancelable.
hiddenEmitted when dropdown is hidden.
toggleEmitted when toggle button is clicked.

Importing individual components

CHANGED in 2.0.0-rc.22 You can import individual components into your project via the following named exports:

ComponentNamed ExportImport Path
<b-nav>BNavbootstrap-vue
<b-nav-item>BNavItembootstrap-vue
<b-nav-text>BNavTextbootstrap-vue
<b-nav-form>BNavFormbootstrap-vue
<b-nav-item-dropdown>BNavItemDropdownbootstrap-vue

Example:

import { BNav } from 'bootstrap-vue'
Vue.component('b-nav', BNav)

Importing as a Vue.js plugin

CHANGED in 2.0.0-rc.22 Importing plugins has been simplified.

This plugin includes all of the above listed individual components. Plugins also include any component aliases.

The plugin can be imported via several methods
Named ExportImport Path
NavPlugin PREFERREDbootstrap-vue
NavPlugin DEPRECATEDbootstrap-vue/es/components
default DEPRECATEDbootstrap-vue/es/components/nav

This plugin also automatically includes the following plugins:

  • DropdownPlugin

Example:

// Importing the named export
import { NavPlugin } from 'bootstrap-vue'
Vue.use(NavPlugin)