Sidenav
Vue Bootstrap 5 Sidenav component
The side navigation component provides an easy way to navigate through your website. Its appearance & behaviour are easily adjustable with data-mdb-attributes and methods - additional functionality such as touch events and focus trap (in an over mode) are available out of the box.
Note: Read the API tab to find all available options and advanced customization
Basic example
In the basic version, the side navigation will appear over your website's content after clicking on a toggler.
Note: Use v-model
property on MDBSideNav
to toggle navigation.
<template>
<!-- Sidenav-->
<MDBSideNav v-model="sidenav1" id="sidenav1">
<MDBSideNavMenu>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 1</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem collapse icon="grin" title="Category 1">
<MDBSideNavItem>
<MDBSideNavLink>Link 2</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Link 3</MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavItem>
<MDBSideNavItem collapse icon="grin-wink" title="Category 2">
<MDBSideNavItem>
<MDBSideNavLink>Link 4</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Link 5</MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavItem>
</MDBSideNavMenu>
</MDBSideNav>
<!-- Sidenav-->
<!-- Toggler -->
<div class="text-center">
<MDBBtn
color="primary"
aria-controls="#sidenav1"
@click="sidenav1 = !sidenav1"
>
<MDBIcon icon="bars" />
</MDBBtn>
</div>
<!-- Toggler -->
</template>
<script>
import { MDBSideNav, MDBSideNavMenu, MDBSideNavItem, MDBSideNavLink, MDBBtn, MDBIcon } from "mdb-vue-ui-kit";
import { ref } from 'vue';
export default {
components: {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBBtn,
MDBIcon
},
setup() {
const sidenav1 = ref(true);
return {
sidenav1
}
}
};
</script>
Inner scroll
Passing a scrollContainer
property to a MDBSideNavMenu
will
initialize MDBScrollbar
on this element (by default it's initialized on the
MDBSideNav
).
<template>
<!-- Sidenav-->
<MDBSideNav v-model="sidenavScroll" id="sidenavScroll">
<div class="text-center">
<h3 class="py-4">Examples</h3>
<hr class="m-0" />
</div>
<MDBSideNavMenu scrollContainer>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 1</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 2</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 3</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 4</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 5</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 6</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 7</span>
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon iconStyle="far" icon="smile" class="fa-fw me-3" />
<span>Link 8</span>
</MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavMenu>
<div class="text-center" style="min-height: 3rem">
<hr class="mt-0 mb-2" />
<small>mdbootstrap.com</small>
</div>
</MDBSideNav>
<!-- Sidenav-->
<!-- Toggler-->
<div style="padding: 20px" class="text-center">
<MDBBtn
color="primary"
aria-controls="#sidenavScroll"
@click="sidenavScroll = !sidenavScroll"
>
<MDBIcon icon="bars" />
</MDBBtn>
</div>
<!-- Toggler-->
</template>
<script>
import { MDBSideNav, MDBSideNavMenu, MDBSideNavItem, MDBSideNavLink, MDBIcon, MDBBtn } from "mdb-vue-ui-kit";
import { ref } from 'vue';
export default {
components: {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon,
MDBBtn
},
setup() {
const sidenavScroll = ref(true);
return {
sidenavScroll
}
}
};
</script>
Full-screen examples
The following examples show various settings of the side navigation component in a full-screen mode.
2. Side navigation with a mode transition
Resize the window to change the mode from side
to over
.
<template>
<!-- Sidenav-->
<MDBSideNav
v-model="sidenavMode"
id="sidenavMode"
:modeBreakpoint="900"
:side="side"
:over="over"
contentSelector="#page-content"
:closeOnEsc="true"
backdropStyle="position: fixed"
>
<div class="mt-4">
<div id="header-content" class="ps-3">
<img
src="https://mdbootstrap.com/img/Photos/Avatars/img%20(23).webp"
alt="avatar"
class="rounded-circle img-fluid mb-3"
style="max-width: 50px;"
/>
<h4>
<span style="white-space: nowrap;">Ann Smith</span>
</h4>
<p>ann_s@mdbootstrap.com</p>
</div>
<hr class="mb-0" />
</div>
<MDBSideNavMenu>
<MDBSideNavItem>
<MDBSideNavLink href="/">
<MDBIcon icon="envelope" class="fas fa-fw me-3"/>
Inbox
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="paper-plane" class="fas fa-fw me-3"/>
Outbox
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem collapse icon="address-book" title="Contacts">
<MDBSideNavItem>
<MDBSideNavLink>Family</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink href="/previews/mdb-ui-kit/sidenav/2.html">
Friends
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Work</MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="file" class="fas fa-fw me-3"/>
Drafts
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="heart" class="fas fa-fw me-3"/>
Favourites
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="star" class="fas fa-fw me-3"/>
Starred
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="trash" class="fas fa-fw me-3"/>
Trash
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="ban" class="fas fa-fw me-3"/>
Spam
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem collapse icon="tag" title="Categories">
<MDBSideNavItem>
<MDBSideNavLink>Social</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Notifications</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Recent</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Uploads</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Backups</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>Offers</MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="sticky-note" class="fas fa-fw me-3"/>
Notes
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="user-circle" class="fas fa-fw me-3"/>
Personal
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="ellipsis-h" class="fas fa-fw me-3"/>
More
</MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavMenu>
<hr class="m-0" />
<MDBSideNavMenu>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="cogs" class="fas fa-fw me-3"/>
Settings
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="user" class="fas fa-fw me-3"/>
Profile
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="shield-alt" class="fas fa-fw me-3"/>
Privacy
</MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem>
<MDBSideNavLink>
<MDBIcon icon="user-astronaut" class="fas fa-fw me-3"/>
Logout
</MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavMenu>
<div class="text-center" style="height: 100px;">
<hr class="mb-4 mt-0" />
<p>MDBootstrap.com</p>
</div>
</MDBSideNav>
<!-- Sidenav-->
<!-- Content-->
<div class="text-center page-intro bg-light" id="page-content">
<div class="text-center py-5">
<h3 class="my-5">Resize to change the mode</h3>
<div>
<img
class="rounded"
style="max-width: 80%"
src="https://mdbootstrap.com/img/Photos/Others/img%20(53).webp"
/>
</div>
<!-- Toggler-->
<MDBBtn
class="mt-5"
color="dark"
aria-controls="#sidenavMode"
@click="sidenavMode = !sidenavMode"
>
<MDBIcon icon="bars" />
</MDBBtn>
<!-- Toggler-->
</div>
</div>
<!-- Content-->
</template>
<script>
import {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon,
MDBBtn
} from "mdb-vue-ui-kit";
import { ref } from "vue";
export default {
components: {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon,
MDBBtn
},
setup() {
const sidenavMode = ref(true);
const side = ref(true);
const over = ref(false);
return {
sidenavMode,
side,
over
};
}
};
</script>
<style>
.page-intro {
background-size: cover;
background-position-x: center;
background-color: white;
width: 100vw;
height: 100vh;
}
</style>
3. Slim side navigation (dark)
Non-expandable slim sidenav with a dark background and custom width.
<template>
<!-- Sidenav-->
<MDBSideNav
v-model="sidenavSlimDark"
id="sidenavSlimDark"
contentSelector="#page-content"
:slim="true"
:slimCollapsed="true"
:slimWidth="90"
color="light"
dark
:backdrop="false"
>
<div class="text-center mt-4">
<a class="ripple rounded-circle" data-mdb-color="light" href="#">
<img
src="https://mdbootstrap.com/img/Photos/Avatars/img%20(29).webp"
alt="avatar"
class="rounded-circle img-fluid"
style="max-width: 60px;"
/>
</a>
</div>
<hr />
<MDBSideNavMenu>
<MDBSideNavItem class="my-3">
<MDBSideNavLink class="p-0 d-flex justify-content-center">
<MDBIcon iconStyle="far" icon="heart" size="2x"></MDBIcon
></MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem class="my-3">
<MDBSideNavLink class="p-0 d-flex justify-content-center">
<MDBIcon iconStyle="far" icon="envelope" size="2x"></MDBIcon
></MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem class="my-3">
<MDBSideNavLink class="p-0 d-flex justify-content-center">
<MDBIcon iconStyle="far" icon="user" size="2x"></MDBIcon
></MDBSideNavLink>
</MDBSideNavItem>
<MDBSideNavItem class="my-3">
<MDBSideNavLink class="p-0 d-flex justify-content-center">
<MDBIcon icon="cogs" size="2x"></MDBIcon
></MDBSideNavLink>
</MDBSideNavItem>
</MDBSideNavMenu>
</MDBSideNav>
<!-- Sidenav-->
<!-- Content-->
<div id="content" class="page-intro">
<div class="mask p-4 text-center">
<h1>Natalie Smith</h1>
<h2>Portfolio</h2>
</div>
</div>
<!-- Content-->
</template>
<script>
import {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon
} from "mdb-vue-ui-kit";
import { ref } from "vue";
export default {
components: {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon
},
setup() {
const sidenavSlimDark = ref(true);
return {
sidenavSlimDark
};
}
};
</script>
<style>
.page-intro {
background-image: url("https://mdbootstrap.com/img/Photos/Others/img%20(52).webp");
background-size: cover;
background-position-x: center;
background-color: white;
width: 100vw;
height: 100vh;
}
.mask {
background-color: rgba(66, 66, 66, 0.4);
width: 100%;
height: 100%;
color: rgba(255, 255, 255, 0.8);
}
.mask h1 {
margin-top: 220px;
font-size: 6rem;
}
.mask h2 {
font-size: 2.8rem;
}
@media (max-width: 500px) {
.mask h1 {
font-size: 4rem;
}
.mask h2 {
font-size: 2rem;
}
}
</style>
Sidenav - API
Import
<script>
import {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
} from 'mdb-vue-ui-kit';
</script>
Properties
SideNav Item
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'li' |
Defines tag of the MDBSideNavItem element |
<MDBSideNavItem tag="div" />
|
SideNav Link
Name | Type | Default | Description | Example |
---|---|---|---|---|
exact
|
Boolean | false |
Sets exact ttribute of the component |
<MDBSideNavLink to="/components/sidenav" exact />
|
href
|
String | '' |
Makes MDBSideNavLink behave like an a element |
<MDBSideNavLink href="https://mdbootstrap.com/" />
|
icon
|
String | '' |
Defines icon. |
<MDBSideNavLink icon="camera" />
|
iconFlag
|
String | '' |
Changes icon to a flag. |
<MDBSideNavLink iconFlag="fr" />
|
iconSize
|
String | '' |
Defines icon size. |
<MDBSideNavLink icon="camera" iconSize="3x" />
|
iconStyle
|
String | 'fas' |
Defines icon style. Available options: fas , far ,
fab , fal , fad .
|
<MDBSideNavLink icon="mdb" iconStyle="fab" />
|
newTab
|
Boolean | false |
Used to have a page opened in a fresh browser's tab. Equivalent to
target="_blank" anchor element attribute
|
<MDBSideNavLink to="/components/sidenav" newTab />
|
ripple
|
[Object, Boolean] | true |
Defines ripple configuration or disables it if false .
|
<MDBSideNavLink :ripple="{ color: 'primary' }" />
|
tag
|
String | 'a' |
Defines tag of the MDBSideNavLink element |
<MDBSideNavLink tag="div" />
|
to
|
String | '' |
Makes MDBSideNavLink behave like a router-link element
|
<MDBSideNavLink to="/components/sidenav" />
|
v-model
|
String | false |
When MDBSideNavLink is used along with MDBCollapse to
create a collapsible category pass a v-model value to both components
for proper functionality
|
<MDBSideNavLink v-model="true" />
|