Sidenav
Angular Bootstrap 5 Sidenav component
The side navigation component provides an easy way to navigate through your website.
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 show
and hide
methods to toggle navigation with
TypeScript.
Inner scroll
Passing a selector of an inner element to the
scrollContainer
option will initialize MDB scrollbar only on this container (by
default it's initialized on the sidenav component).
Active links
Use Angular routerLinkActive
directive to add .active
class to the navigation element that leads to the active route. Navigation menu will automatically expand to show active link.
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
.
3. Slim side navigation (dark)
Non-expandable slim sidenav with a dark background and custom width.
Sidenav small and with categories
Sidenav - API
Import
Inputs
Name | Type | Default | Description |
---|---|---|---|
accordion
|
Boolean | false |
Enables accordion behaviour in a navigation container |
backdrop
|
Boolean | true |
Adds/removes a backdrop in an over mode |
backdropClass
|
String | - |
Adds a custom class to a backdrop |
closeOnEsc
|
Boolean | true |
Closes a side drawer on ESC key (only when toggler is visible) |
color
|
String | primary |
Changes a color of active/hovered links and categories |
disableWindowScroll
|
Boolean | false |
Disables window scroll when sidenav is open. |
expandOnHover
|
Boolean | false |
Expands/collapses slim mode on mouseover / mouseleave |
focusTrap
|
Boolean | true |
Toggles focus trap feature in component template |
hidden
|
Boolean | true |
Initializes navigation outside a viewport |
mode |
String | over |
Sets position mode - available options: over, side, push |
scrollContainer
|
String |
|
Selector for a scrollable container inside a side drawer |
slim |
Boolean | false |
Enables a slim mode |
slimCollapsed
|
Boolean | false |
Initializes a component in a slim mode |
slimWidth
|
Number | 77 |
A component's width in a slim mode (pixels) |
position
|
String | fixed |
Sets CSS position - accepted values: fixed, absolute |
right |
Boolean | false |
Initializes sidenav on a right side |
transitionDuration
|
Number | 300 |
Sets a length of transitions (in milliseconds) |
width |
Number | 240 |
A component's width (pixels) |
Outputs
Name | Type | Description |
---|---|---|
sidenavShow
|
EventEmitter<any> | Emitted when a component has been toggled |
sidenavShown
|
EventEmitter<any> | Emitted once a component is shown (after transition) |
sidenavHide
|
EventEmitter<any> | Emitted when a component has been toggled |
sidenavHidden
|
EventEmitter<any> | Emitted once a component is hidden (after transition) |
sidenavExpand
|
EventEmitter<any> | Emitted when a slim mode has been toggled |
sidenavExpanded
|
EventEmitter<any> | Emitted once a component has expanded from a slim mode (after transition) |
sidenavCollapse
|
EventEmitter<any> | Emitted when a slim mode has been toggled |
sidenavCollapsed
|
EventEmitter<any> | Emitted once a component has collapsed into a slim mode (after transition) |
sidenavUpdate
|
EventEmitter<any> | Emitted whenever a content's offset should be updated (push/side mode). |
Methods
Name | Description | Example |
---|---|---|
setMode
|
Changes a position mode (options: over, side, push) |
sidenav.setMode('push')
|
hide |
Hides a navigation drawer |
sidenav.hide()
|
show |
Shows a navigation drawer |
sidenav.show()
|
toggle |
Manually toggles a component |
sidenav.toggle()
|
toggleSlim
|
Manually toggles a slim state |
sidenav.toggleSlim()
|
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.