Nav
Bootstrap's vue nav component is a simple wrapper for building navigation components.
HTML
template
<BNav>
<BNavItem>Home</BNavItem>
<BNavItem>About</BNavItem>
<BNavItem>New</BNavItem>
<BNavItem disabled>Home</BNavItem>
</BNav>
Dropdown
Dropdowns can be added like so
HTML
vue
<template>
<BNav pills>
<BNavItem active>Active</BNavItem>
<BNavItem>Link</BNavItem>
<BNavItemDropdown
v-model="dropdownShow"
id="my-nav-dropdown"
text="Dropdown"
toggle-class="nav-link-custom"
end
>
<BDropdownItem>One</BDropdownItem>
<BDropdownItem>Two</BDropdownItem>
<BDropdownDivider />
<BDropdownItem>Three</BDropdownItem>
</BNavItemDropdown>
</BNav>
</template>
<script setup lang="ts">
const dropdownShow = ref(false)
</script>
BNavItemDropdown
has many props in common with <BDropdown
so you can easily integrate custom options.
Styles
You can make nav item styles in various ways.
Tab Style
HTML
template
<BNav tabs>
<BNavItem active>Active</BNavItem>
<BNavItem>Link</BNavItem>
<BNavItem>Another Link</BNavItem>
<BNavItem disabled>Disabled</BNavItem>
</BNav>
Pills Style
HTML
template
<BNav pills>
<BNavItem active>Active</BNavItem>
<BNavItem>Link</BNavItem>
<BNavItem>Another Link</BNavItem>
<BNavItem disabled>Disabled</BNavItem>
</BNav>
Vertical Orientation
By default BNav
appear on a horizontal line. Stack your navigation by setting the vertical prop.
HTML
template
<BNav vertical class="w-25">
<BNavItem active>Active</BNavItem>
<BNavItem>Link</BNavItem>
<BNavItem>Another Link</BNavItem>
<BNavItem disabled>Disabled</BNavItem>
</BNav>
Nav Text
Use the BNavText
child component to place plain text content into the nav:
HTML
template
<BNav>
<BNavItem href="#1">Link 1</BNavItem>
<BNavItem href="#2">Link 2</BNavItem>
<BNavText>Plain text</BNavText>
</BNav>
Component Reference
<BNav>
Prop | Type | Default | Description |
---|---|---|---|
align | AlignmentJustifyContent | undefined | |
card-header | boolean | false | |
fill | boolean | false | |
justified | boolean | false | |
pills | boolean | false | |
small | boolean | false | |
tabs | boolean | false | |
tag | string | 'ul' | |
underline | boolean | false | |
vertical | boolean | false |
Name | Scope | Description |
---|---|---|
default |
<BNavForm>
Prop | Type | Default | Description |
---|---|---|---|
floating | boolean | undefined | |
id | string | undefined | |
novalidate | boolean | undefined | |
role | string | undefined | |
validated | boolean | undefined |
Event | Args | Description |
---|---|---|
submit | submit : Event |
Name | Scope | Description |
---|---|---|
default |
<BNavItem>
Prop | Type | Default | Description |
---|---|---|---|
active | boolean | undefined | |
active-class | string | undefined | |
disabled | boolean | undefined | |
exact-active-class | string | undefined | |
href | string | undefined | |
icon | boolean | undefined | |
link-attrs | Readonly<AttrsValue> | undefined | |
link-class | ClassValue | undefined | |
no-prefetch |
| undefined | |
no-rel |
| undefined | |
opacity | 10 | 25 | 50 | 75 | 100 | '10' | '25' | '50' | '75' | '100' | undefined | |
opacity-hover | 10 | 25 | 50 | 75 | 100 | '10' | '25' | '50' | '75' | '100' | undefined | |
prefetch |
| undefined | |
prefetched-class |
| undefined | |
rel | string | undefined | |
replace | boolean | undefined | |
router-component-name | string | undefined | |
stretched | boolean | false | |
target | LinkTarget | undefined | |
to | RouteLocationRaw | undefined | |
underline-offset | 1 | 2 | 3 | '1' | '2' | '3' | undefined | |
underline-offset-hover | 1 | 2 | 3 | '1' | '2' | '3' | undefined | |
underline-opacity | 0 | 10 | 25 | 50 | 75 | 100 | '0' | '10' | '25' | '50' | '75' | '100' | undefined | |
underline-opacity-hover | 0 | 10 | 25 | 50 | 75 | 100 | '0' | '10' | '25' | '50' | '75' | '100' | undefined | |
underline-variant | ColorVariant | null | undefined | |
variant | ColorVariant | null | undefined |
Event | Args | Description |
---|---|---|
click | click : MouseEvent - On click event |
Name | Scope | Description |
---|---|---|
default |
<BNavItemDropdown>
Prop | Type | Default | Description |
---|---|---|---|
aria-label | string | undefined | Sets the value of `aria-label` attribute on the rendered element |
auto-close | boolean | 'inside' | 'outside' | true | |
boundary | Boundary | RootBoundary | 'clippingAncestors' | |
boundary-padding | Padding | undefined | |
disabled | boolean | false | When set to `true`, disables the component's functionality and places it in a disabled state |
floating-middleware | Middleware[] | undefined | |
id | string | undefined | Used to set the `id` attribute on the rendered content, and used as the base to generate any additional element IDs as needed |
is-nav | boolean | true | |
lazy | boolean | false | |
menu-class | ClassValue | undefined | |
model-value | boolean | false | |
no-caret | boolean | false | |
no-flip | boolean | false | |
no-shift | boolean | false | |
no-size | boolean | false | |
offset | number | string | {mainAxis?: number | string; crossAxis?: number; alignmentAxis?: number | null} | 0 | |
placement | Placement | 'bottom-start' | Placement of a floating element |
role | string | undefined | Sets the ARIA attribute `role` to a specific value |
size | Size | 'md' | Set the size of the component's appearance. 'sm', 'md' (default), or 'lg' |
skip-wrapper | boolean | undefined | |
split | boolean | false | |
split-button-type | ButtonType | 'button' | |
split-class | ClassValue | undefined | |
split-disabled | boolean | undefined | |
split-href | string | undefined | |
split-to | RouteLocationRaw | undefined | |
split-variant | ButtonVariant | null | undefined | |
strategy | Strategy | 'absolute' | |
teleport-disabled | boolean | false | |
teleport-to | string | RendererElement | null | undefined | undefined | |
text | string | undefined | |
toggle-class | ClassValue | undefined | |
toggle-text | string | 'Toggle dropdown' | |
variant | ButtonVariant | null | 'link' | |
wrapper-class | ClassValue | undefined |
Event | Args | Description |
---|---|---|
click | click : MouseEvent | |
hidden | ||
hide | value : BvTriggerableEvent | |
hide-prevented | Emitted when the dropdown tried to close, but was prevented from doing so. | |
show | value : BvTriggerableEvent | |
show-prevented | Emitted when the dropdown tried to open, but was prevented from doing so. | |
shown | ||
toggle | ||
update:model-value | value : boolean - The new value of the dropdown's state | Emitted when the dropdown state changes |
Name | Scope | Description |
---|---|---|
button-content | ||
default | ||
toggle-text | hide : () => void show : () => void |
<BNavText>
Prop | Type | Default | Description |
---|---|---|---|
text | string | undefined |
Name | Scope | Description |
---|---|---|
default |