Offcanvas
Offcanvas
You can use a link with the href attribute, or a button with the data-bs-target attribute. In both cases, the data-bs-toggle="offcanvas" is required.
Offcanvas
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
<a class="btn btn-info" data-bs-toggle="offcanvas" href="#offcanvasExample" role="button" aria-controls="offcanvasExample">
Link with href
</a>
<div class="offcanvas offcanvas-start" tabindex="-1" id="offcanvasExample" aria-labelledby="offcanvasExampleLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasExampleLabel">Offcanvas</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- / offcanvas-header -->
<div class="offcanvas-body">
<p>
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
</p>
<div class="dropdown mt-15">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown">
Dropdown button
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div><!-- / dropdown -->
</div><!-- / offcanvas-body -->
</div><!-- / offcanvas -->
Offcanvas Placement
There’s no default placement for offcanvas components, so you must add one of the modifier classes below;
.offcanvas-startplaces offcanvas on the left of the viewport (shown above).offcanvas-endplaces offcanvas on the right of the viewport.offcanvas-topplaces offcanvas on the top of the viewport.offcanvas-bottomplaces offcanvas on the bottom of the viewport
Offcanvas top
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
- Quisque luctus risus quis.
- Ut porta iaculis velit.
- Praesent vitae ac justo.
- Aenean et porttitor eros.
Offcanvas right
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
- Quisque luctus risus quis.
- Ut porta iaculis velit.
- Praesent vitae ac justo.
- Aenean et porttitor eros.
Offcanvas bottom
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
- Quisque luctus risus quis.
- Ut porta iaculis velit.
- Praesent vitae ac justo.
- Aenean et porttitor eros.
Offcanvas left
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
- Quisque luctus risus quis.
- Ut porta iaculis velit.
- Praesent vitae ac justo.
- Aenean et porttitor eros.
<!-- top offcanvas -->
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasTop" aria-controls="offcanvasTop">Top Offcanvas</button>
<div class="offcanvas offcanvas-top" tabindex="-1" id="offcanvasTop" aria-labelledby="offcanvasTopLabel">
<div class="offcanvas-header">
<h5 id="offcanvasTopLabel">Offcanvas top</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- / offcanvas-header -->
<div class="offcanvas-body">
...
</div><!-- offcanvas-body -->
</div><!-- / offcanvas-top -->
<!-- right offcanvas -->
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight">Right Offcanvas</button>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight" aria-labelledby="offcanvasRightLabel">
<div class="offcanvas-header">
<h5 id="offcanvasRightLabel">Offcanvas right</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- / offcanvas-header -->
<div class="offcanvas-body">
...
</div><!-- offcanvas-body -->
</div><!-- / offcanvas-end -->
<!-- bottom offcanvas -->
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasBottom" aria-controls="offcanvasBottom">Bottom Offcanvas</button>
<div class="offcanvas offcanvas-bottom" tabindex="-1" id="offcanvasBottom" aria-labelledby="offcanvasBottomLabel">
<div class="offcanvas-header">
<h5 id="offcanvasBottomLabel">Offcanvas bottom</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- / offcanvas-header -->
<div class="offcanvas-body">
...
</div><!-- offcanvas-body -->
</div><!-- / offcanvas-bottom -->
<!-- left offcanvas -->
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasLeft" aria-controls="offcanvasLeft">Left Offcanvas</button>
<div class="offcanvas offcanvas-start" tabindex="-1" id="offcanvasLeft" aria-labelledby="offcanvasLeftLabel">
<div class="offcanvas-header">
<h5 id="offcanvasLeftLabel">Offcanvas left</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- / offcanvas-header -->
<div class="offcanvas-body">
...
</div><!-- offcanvas-body -->
</div><!-- / offcanvas-start -->
Offcanvas Backdrop
Scrolling the <body> element is disabled when an offcanvas and its backdrop are visible. Use the data-bs-scroll attribute to toggle <body> scrolling and data-bs-backdrop to toggle the backdrop.
Colored with scrolling
Try scrolling the rest of the page to see this option in action.
Backdrop with scrolling
Try scrolling the rest of the page to see this option in action.
<button class="btn btn-info" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling" aria-controls="offcanvasScrolling">Enable body scrolling</button>
<button class="btn btn-success" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasWithBothOptions" aria-controls="offcanvasWithBothOptions">Enable both scrolling & backdrop</button>
<div class="offcanvas offcanvas-start" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" id="offcanvasScrolling" aria-labelledby="offcanvasScrollingLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasScrollingLabel">Colored with scrolling</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- / offcanvas-header -->
<div class="offcanvas-body">
<p>Try scrolling the rest of the page to see this option in action.</p>
</div><!-- / offcanvas-body -->
</div><!-- / offcanvas -->
<div class="offcanvas offcanvas-start" data-bs-scroll="true" tabindex="-1" id="offcanvasWithBothOptions" aria-labelledby="offcanvasWithBothOptionsLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasWithBothOptionsLabel">Backdrop with scrolling</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div><!-- / offcanvas-header -->
<div class="offcanvas-body">
<p>Try scrolling the rest of the page to see this option in action.</p>
</div><!-- / offcanvas-body -->
</div><!-- / offcanvas -->