--- layout: docs title: Offcanvas description: Build hidden sidebars into your project for navigation, shopping carts, and more with a few classes and our JavaScript plugin. group: components toc: true --- ## How it works Offcanvas is a sidebar component that can be toggled via JavaScript to appear from the left, right, top, or bottom edge of the viewport. Buttons or anchors are used as triggers that are attached to specific elements you toggle, and `data` attributes are used to invoke our JavaScript. - Offcanvas shares some of the same JavaScript code as modals. Conceptually, they are quite similar, but they are separate plugins. - Similarly, some [source Sass](#sass) variables for offcanvas's styles and dimensions are inherited from the modal's variables. - When shown, offcanvas includes a default backdrop that can be clicked to hide the offcanvas. - Similar to modals, only one offcanvas can be shown at a time. **Heads up!** Given how CSS handles animations, you cannot use `margin` or `translate` on an `.offcanvas` element. Instead, use the class as an independent wrapping element. {{< callout info >}} {{< partial "callout-info-prefersreducedmotion.md" >}} {{< /callout >}} ## Examples ### Offcanvas components Below is an offcanvas example that is shown by default (via `.show` on `.offcanvas`). Offcanvas includes support for a header with a close button and an optional body class for some initial `padding`. We suggest that you include offcanvas headers with dismiss actions whenever possible, or provide an explicit dismiss action. {{< example class="bd-example-offcanvas p-0 bg-light overflow-hidden" >}}
Try scrolling the rest of the page to see this option in action.
Try scrolling the rest of the page to see this option in action.
This is content within an .offcanvas-lg
.