Links

Use BootstrapVue's custom b-link component for generating a standard <a> link or <router-link>. <b-link> supports the disabled state and click event propagation.

<b-link> is the building block for most BootstrapVue components that offer link functionality.

<div>
  <b-link href="#foo">Link</b-link>
</div>

<!-- b-link.vue -->

By specifying a value in the href prop, a standard link (<a>) element will be rendered. To generate a <router-link> instead, specify the route location via the to prop.

Router links support various additional props. Refer to the Router support reference section for details.

If your app is running under Nuxt.js, the <nuxt-link> component will be used instead of <router-link>. The <nuxt-link> component supports all the same features as <router-link> (as it is a wrapper component for <router-link>) and more.

BootstrapVue auto detects using <router-link> and <nuxt-link> link components. Some 3rd party frameworks also provide customized versions of <router-link>, such as Gridsome's <g-link> component. <b-link> can support these third party <router-link> compatible components via the use of the router-component-name prop. All vue-router props (excluding <nuxt-link> specific props) will be passed to the specified router link component.

Note that the 3rd party component will only be used when the to prop is set.

Typically <a href="#"> will cause the document to scroll to the top of page when clicked. <b-link> addresses this by preventing the default action (scroll to top) when href is set to #.

If you need scroll to top behaviour, use a standard <a href="#">...</a> tag.

Disable link functionality by setting the disabled prop to true.

<div>
  <b-link href="#foo" disabled>Disabled Link</b-link>
</div>

<!-- b-link-disabled.vue -->

Disabling a link will set the Bootstrap v4 .disabled class on the link as well as handles stopping event propagation, preventing the default action from occurring, and removing the link from the document tab sequence (tabindex="-1").

Note: Bootstrap v4 CSS currently does not style disabled links differently than non-disabled links. You can use the following custom CSS to style disabled links (by preventing hover style changes):

a.disabled {
  pointer-events: none;
}

Not all browsers support pointer-events: none;.

Component reference

Property
(Click to sort Ascending)
Type
Default
Description
href
StringDenotes the target URL of the link for standard a links
rel
StringnullSets the 'rel' attribute on the rendered link
target
String'_self'Sets the 'target' attribute on the rendered link
active
BooleanfalseWhen set to `true`, places the component in the active state with active styling
disabled
BooleanfalseWhen set to `true`, disables the component's functionality and places it in a disabled state
to
String or Object<router-link> prop: Denotes the target route of the link. When clicked, the value of the to prop will be passed to `router.push()` internally, so the value can be either a string or a Location descriptor object
append
Booleanfalse<router-link> prop: Setting append prop always appends the relative path to the current path
replace
Booleanfalse<router-link> prop: Setting the replace prop will call `router.replace()` instead of `router.push()` when clicked, so the navigation will not leave a history record
event
String or Array'click'<router-link> prop: Specify the event that triggers the link. In most cases you should leave this as the default
active-class
String<router-link> prop: Configure the active CSS class applied when the link is active. Typically you will want to set this to class name 'active'
exact
Booleanfalse<router-link> prop: The default active class matching behavior is inclusive match. Setting this prop forces the mode to exactly match the route
exact-active-class
String<router-link> prop: Configure the active CSS class applied when the link is active with exact match. Typically you will want to set this to class name 'active'
router-tag
String'a'<router-link> prop: Specify which tag to render, and it will still listen to click events for navigation. `router-tag` translates to the tag prop on the final rendered `<router-link>`. Typically you should use the default value
prefetch
v2.15.0+
Booleannull<nuxt-link> prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting `prefetch` to `true` or `false` will overwrite the default value of `router.prefetchLinks`
no-prefetch
Booleanfalse<nuxt-link> prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting `no-prefetch` will disabled this feature for the specific link
router-component-name
Settings v2.15.0+
String<b-link> prop: BootstrapVue auto detects between `<router-link>` and `<nuxt-link>`. In cases where you want to use a 3rd party link component based on `<router-link>`, set this prop to the component name. e.g. set it to 'g-link' if you are using Gridsome (note only `<router-link>` specific props are passed to the component)

<b-link> supports generating <router-link> or <nuxt-link> component (if using Nuxt.js). For more details on the router link (or nuxt link) specific props, see the Router support reference section.

Event
Arguments
Description
click
  1. Native click event
when link clicked

Importing individual components

You can import individual components into your project via the following named exports:

Component
Named Export
Import Path
<b-link>BLinkbootstrap-vue

Example:

import { BLink } from 'bootstrap-vue'
Vue.component('b-link', BLink)

Importing as a Vue.js plugin

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

Named Export
Import Path
LinkPluginbootstrap-vue

Example:

import { LinkPlugin } from 'bootstrap-vue'
Vue.use(LinkPlugin)