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>
<script setup lang="ts">
import {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBBtn,
MDBIcon
} from "mdb-vue-ui-kit";
import { ref } from 'vue';
const sidenav1 = ref(true);
</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>
<script setup lang="ts">
import {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon,
MDBBtn
} from "mdb-vue-ui-kit";
import { ref } from 'vue';
const sidenavScroll = ref(true);
</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>
<script setup lang="ts">
import {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon,
MDBBtn
} from "mdb-vue-ui-kit";
import { ref } from "vue";
const sidenavMode = ref(true);
const side = ref(true);
const over = ref(false);
</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>
<script setup lang="ts">
import {
MDBSideNav,
MDBSideNavMenu,
MDBSideNavItem,
MDBSideNavLink,
MDBIcon
} from "mdb-vue-ui-kit";
import { ref } from "vue";
const sidenavSlimDark = ref(true);
</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
CSS variables
As part of MDB’s evolving CSS variables approach, sidenav now use local CSS variables on .sidenav
and .sidenav-backdrop
for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Sidenav CSS variables are in different classes which belong to this component. To make it easier to use them, you can find below all of the used CSS variables.
// .sidenav
--#{$prefix}sidenav-transform: #{$sidenav-transform};
--#{$prefix}sidenav-zindex: #{$sidenav-zindex};
--#{$prefix}sidenav-background-color: #{$sidenav-background-color};
--#{$prefix}sidenav-width: #{$sidenav-width};
--#{$prefix}sidenav-height: #{$sidenav-height};
--#{$prefix}sidenav-box-shadow: #{$sidenav-box-shadow};
--#{$prefix}sidenav-data-hidden-false-transform: #{$sidenav-data-hidden-false-transform};
--#{$prefix}sidenav-data-color-light-color: #{$sidenav-data-color-light-color};
--#{$prefix}sidenav-data-right-true-transform: #{$sidenav-data-right-true-transform};
--#{$prefix}sidenav-data-slim-collapsed-true-width: #{$sidenav-data-slim-collapsed-true-width};
--#{$prefix}sidenav-menu-padding: #{$sidenav-menu-padding};
--#{$prefix}sidenav-collapse-sidenav-link-font-size: #{$sidenav-collapse-sidenav-link-font-size};
--#{$prefix}sidenav-collapse-sidenav-link-height: #{$sidenav-collapse-sidenav-link-height};
--#{$prefix}sidenav-link-font-size: #{$sidenav-link-font-size};
--#{$prefix}sidenav-link-padding-y: #{$sidenav-link-padding-y};
--#{$prefix}sidenav-link-padding-x: #{$sidenav-link-padding-x};
--#{$prefix}sidenav-link-height: #{$sidenav-link-height};
--#{$prefix}sidenav-link-border-radius: #{$sidenav-link-border-radius};
--#{$prefix}sidenav-link-transition: #{$sidenav-link-transition};
--#{$prefix}sidenav-link-hover-background-color: #{$sidenav-link-hover-background-color};
--#{$prefix}sidenav-link-active-focus-background-color: #{$sidenav-link-active-focus-background-color};
--#{$prefix}sidenav-link-active-color: #{$sidenav-link-active-color};
--#{$prefix}sidenav-subheading-font-size: #{$sidenav-subheading-font-size};
--#{$prefix}sidenav-subheading-padding-y: #{$sidenav-subheading-padding-y};
--#{$prefix}sidenav-subheading-padding-x: #{$sidenav-subheading-padding-x};
--#{$prefix}sidenav-subheading-fw: #{$sidenav-subheading-fw};
--#{$prefix}sidenav-sm-link-pt: #{$sidenav-sm-link-pt};
--#{$prefix}sidenav-sm-link-pb: #{$sidenav-sm-link-pb};
--#{$prefix}sidenav-rotate-icon-margin-right: #{$sidenav-rotate-icon-margin-right};
--#{$prefix}sidenav-rotate-icon-transition: #{$sidenav-rotate-icon-transition};
--#{$prefix}sidenav-light-color: #{$sidenav-light-color};
// .sidenav-backdrop
--#{$prefix}sidenav-backdrop-zindex: #{$sidenav-backdrop-zindex};
--#{$prefix}sidenav-backdrop-background-color: #{$sidenav-backdrop-background-color};
SCSS variables
$sidenav-zindex: 1035;
$sidenav-backdrop-zindex: 1034;
$sidenav-transform: translateX(-100%);
$sidenav-background-color: $white;
$sidenav-width: 240px;
$sidenav-height: 100vh;
$sidenav-box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05);
$sidenav-data-hidden-false-transform: translateX(0%);
$sidenav-data-color-light-color: rgba(255, 255, 255, 0.6);
$sidenav-data-right-true-transform: translateX(100%);
$sidenav-data-slim-collapsed-true-width: 77px;
$sidenav-menu-padding: 0.2rem;
$sidenav-collapse-sidenav-link-font-size: 0.78rem;
$sidenav-collapse-sidenav-link-height: 1.5rem;
$sidenav-collapse-sidenav-link-padding-left: 3rem;
$sidenav-link-font-size: 0.89rem;
$sidenav-link-padding-y: 1rem;
$sidenav-link-padding-x: 1.5rem;
$sidenav-link-height: 3rem;
$sidenav-link-border-radius: 5px;
$sidenav-link-transition: all 0.3s linear;
$sidenav-link-hover-color: $primary;
$sidenav-link-hover-background-color: #f6f9fc;
$sidenav-link-active-focus-color: $sidenav-link-hover-color;
$sidenav-link-active-focus-background-color: $sidenav-link-hover-background-color;
$sidenav-link-active-color: $sidenav-link-hover-color;
$sidenav-rotate-icon-margin-right: 0.8rem;
$sidenav-rotate-icon-transition: transform 0.3s;
$sidenav-backdrop-background-color: rgba(0, 0, 0, 0.1);
$sidenav-light-color: $sidenav-data-color-light-color;
$sidenav-subheading-font-size: 0.6rem;
$sidenav-subheading-padding-y: 1rem;
$sidenav-subheading-padding-x: 1.5rem;
$sidenav-subheading-fw: 700;
$sidenav-sm-link-pt: 0.4rem;
$sidenav-sm-link-pb: $sidenav-sm-link-pt;