Static method which allows you to get the offcanvas instance associated with a DOM element before the hidden.bs.offcanvas event occurs). Returns to the caller before the offcanvas element has actually been hidden (i.e. before the shown.bs.offcanvas event occurs). Returns to the caller before the offcanvas element has actually been shown (i.e. before the shown.bs.offcanvas or hidden.bs.offcanvas event occurs). Returns to the caller before the offcanvas element has actually been shown or hidden (i.e. Toggles an offcanvas element to shown or hidden. getElementById ( 'myOffcanvas' ) var bsOffcanvas = new bootstrap. If you’d like it to default open, add the additional class show. Be sure to add the class offcanvas to the offcanvas element. The data-bs-target attribute accepts a CSS selector to apply the offcanvas to. Via data attributesĪdd data-bs-toggle="offcanvas" and a data-bs-target or href to the element to automatically assign control of one offcanvas element. Be sure to use the element with it for proper behavior across all devices. offcanvas-bottom hides the offcanvas on the bottomĪdd a dismiss button with the data-bs-dismiss="offcanvas" attribute, which triggers the JavaScript functionality. offcanvas-end hides the offcanvas on the right offcanvas-start hides the offcanvas on the left The offcanvas plugin utilizes a few classes and attributes to handle the heavy lifting: 3 s $offcanvas-border-color : $modal-content-border-color $offcanvas-border-width : $modal-content-border-width $offcanvas-title-line-height : $modal-title-line-height $offcanvas-bg-color : $modal-content-bg $offcanvas-color : $modal-content-color $offcanvas-box-shadow : $modal-content-box-shadow-xs Usage $offcanvas-padding-y : $modal-inner-padding $offcanvas-padding-x : $modal-inner-padding $offcanvas-horizontal-width : 400 px $offcanvas-vertical-height : 30 vh $offcanvas-transition-duration. Note that you don’t need to add role="dialog" since we already add it via JavaScript. Since the offcanvas panel is conceptually a modal dialog, be sure to add aria-labelledby="."-referencing the offcanvas title-to. Backdroped with scrolling Try scrolling the rest of the page to see this option in action. Try the top, right, and bottom examples out below.Įnable body scrolling Enable backdrop (default) Enable both scrolling & backdrop Colored with scrolling Try scrolling the rest of the page to see this option in action. offcanvas-bottom places offcanvas on the bottom of the viewport offcanvas-top places offcanvas on the top of the viewport offcanvas-end places offcanvas on the right of the viewport offcanvas-start places offcanvas on the left of the viewport (shown above) There’s no default placement for offcanvas components, so you must add one of the modifier classes below Action Another action Something else here Placement In real life you can have the elements you have chosen.