Link

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

By defaut links with no options will default to # location.

HTML
template
  <BLink>Link</BLink>

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.

HTML
template
<BLink href="https://getbootstrap.com/docs/5.3" target="_blank" rel="noopener">
  External Link to Bootstrap
</BLink>

<BLink to="sample">
  To page sample
</BLink>

<BLink href="#comp-ref--props">
  Jump to Properties
</BLink>

External Links can be specified with the href prop.

HTML
template
<BLink class="btn btn-primary m-2" href="https://getbootstrap.com/docs/5.3" target="_blank" rel="noopener">
  External Link to Bootstrap
</BLink>

<BLink class="btn btn-primary disabled m-2" href="https://getbootstrap.com/docs/5.3" target="_blank" rel="noopener">
  Disabled Link
</BLink>

Change the alpha opacity of the link rgba() color value. Please be aware that changes to a color’s opacity can lead to links with insufficient contrast.

HTML
template
<p v-for="opacity in [10, 25, 50, 75, 100]" :key="opacity">
  <BLink :opacity="opacity"> {{ opacity }} link </BLink>
</p>

You can even change the opacity level on hover.

HTML
template
<p v-for="opacity in [10, 25, 50, 75, 100]" :key="opacity">
  <BLink :opacity-hover="opacity"> {{ opacity }} link </BLink>
</p>

Underline color

Change the underline’s color independent of the link text color.

HTML
template
<p
  v-for="color in [
    'primary',
    'secondary',
    'success',
    'danger',
    'warning',
    'info',
    'light',
    'dark',
  ]"
  :key="color"
>
  <BLink :underline-variant="color"> {{ color }} link </BLink>
</p>

Underline offset

Change the underline’s distance from your text. Offset is set in em units to automatically scale with the element’s current font-size.

HTML
template
<p v-for="offset in [1, 2, 3]" :key="offset">
  <BLink :underline-offset="offset"> {{ offset }} link </BLink>
</p>

Underline opacity

Change the underline’s opacity.

HTML
template
<p v-for="opacity in [0, 10, 25, 50, 75, 100]" :key="opacity">
  <BLink :underline-opacity="opacity"> {{ opacity }} link </BLink>
</p>

Hover variants

Just like the setting opacity has a matching opacity-hover prop, underline-offset and underline-opacity have matching underline-offset-hover and underline-opacity-hover props. Mix and match to create unique link styles.

HTML
template
<BLink
  :underline-offset="3"
  underline-opacity="25"
  underline-offset-hover="1"
  underline-opacity-hover="100"
>
  Mutliple variants
</BLink>

You can use the variant prop to colorize links. Some of the link styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.

HTML
template
<p
  v-for="color in [
    'primary',
    'secondary',
    'success',
    'danger',
    'warning',
    'info',
    'light',
    'dark',
  ]"
  :key="color"
>
  <BLink :variant="color"> {{ color }} link </BLink>
</p>

Disable link functionality by setting the disabled prop to true.

HTML
template
  <BLink href="#foo" disabled>Disabled Link</BLink>

Disabling a link will set the Bootstrap v5 .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").

css
a.disabled {
  pointer-events: none;
}

Component Reference

PropTypeDefaultDescription
activebooleanundefined When set to `true`, places the component in the active state with active styling
active-classstring'router-link-active' Configure the active CSS class applied when the link is active.
disabledbooleanfalse When set to `true`, disables the link's functionality. See above for details and limitations
exact-active-classstring'router-link-exact-active' Configure the active CSS class applied when the link is active with exact match.
hrefstringundefined Denotes the target URL of the link for standard a links
iconbooleanfalse When set to `true`, styles an icon at the beginning or end of the link text
no-prefetchbooleanfalseNot yet implemented 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
no-relundefined
opacity10 | 25 | 50 | 75 | 100 | '10' | '25' | '50' | '75' | '100'undefined Change the alpha opacity of the link `rgba()` color value
opacity-hover10 | 25 | 50 | 75 | 100 | '10' | '25' | '50' | '75' | '100'undefined Change the alpha opacity of the link `rgba()` color value on hover
prefetchbooleanundefined 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`
prefetch-onPartial<{visibility: boolean, interaction: boolean}>undefined Allows custom control of when to prefetch links. Possible options are 'interaction' and 'visibility' (default).
prefetched-classstringundefined Not Yet Implmented: A class to apply to links that have been prefetched.
relstringundefined Sets the 'rel' attribute on the rendered link
replacebooleanfalse Setting replace prop will call router.replace() instead of router.push() when clicked
router-component-namestring'router-link' BootstrapVue auto detects between `<router-link>` and `<nuxt-link>`. Set this this property to explicity set the name of the router component.
router-tagstring'a' Set the tag type for the link
stretchedbooleanfalse When set to `true`, makes the link's `containing block` clickable via an `::after` pseudo element
targetLinkTargetundefined Sets the 'target' attribute on the rendered link
toRouteLocationRawundefined Denotes the target route of the link. When clicked, the value of the to prop will be passed to `router.push()` internally
underline-offset1 | 2 | 3 | '1' | '2' | '3'undefined Change the distance of the underline from the bottom of the link text
underline-offset-hover1 | 2 | 3 | '1' | '2' | '3'undefined Change the distance of the underline from the bottom of the link text on hover
underline-opacity0 | 10 | 25 | 50 | 75 | 100 | '0' | '10' | '25' | '50' | '75' | '100'undefined Set's the opacity of the link's underline
underline-opacity-hover0 | 10 | 25 | 50 | 75 | 100 | '0' | '10' | '25' | '50' | '75' | '100'undefined Set's the opacity of the link's underline on hover
underline-variantColorVariant | nullnull Set the color variant for the link underline independently of the link text
variantColorVariant | nullnull Set the color variant for the link
EventArgsDescription
click
value: MouseEvent - Native click event
Emitted when link was clicked
NameScopeDescription
defaultContent to place in the link