Skip to the page content

Offcanvas

Panels that slide in from an edge, including drawers and sheets.

Bootstrap reference

10 panel types

Edge placement

Bootstrap's four edges: .offcanvas-start, -end, -top and -bottom. Click an edge of the screen below to slide a panel in from there. Width and height are set with --bs-offcanvas-width and --bs-offcanvas-height.

Placement
Show code
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas"
        data-bs-target="#panel" aria-controls="panel">Open</button>

<div class="offcanvas offcanvas-start" tabindex="-1" id="panel" role="dialog" aria-labelledby="panel-title">
  <div class="offcanvas-header">
    <h2 class="offcanvas-title" id="panel-title">Start</h2>
    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body">…</div>
</div>
<!-- offcanvas-end, offcanvas-top, offcanvas-bottom for the other edges -->

Static backdrop

With data-bs-backdrop="static" a click outside does nothing, so a half-filled form survives. Esc and the buttons still close it.

Behavior

Open it, then click the dimmed page. The panel stays where it is.

Show code
<div class="offcanvas offcanvas-end" tabindex="-1" id="new-customer"
     data-bs-backdrop="static" aria-labelledby="new-customer-title">
  …
</div>

Page scrolling behind

By default the page behind is locked. data-bs-scroll="true" lets it scroll, with or without the backdrop, for a panel you keep open while reading.

Behavior

Open one, then scroll the page. It moves under the panel.

Show code
<!-- Page scrolls, no backdrop -->
<div class="offcanvas offcanvas-start" data-bs-scroll="true" data-bs-backdrop="false" …>…</div>

<!-- Page scrolls, backdrop shown -->
<div class="offcanvas offcanvas-start" data-bs-scroll="true" …>…</div>

Resizable drawer

Drag the drawer's inner edge to make it wider or narrower, or focus the edge and use the arrow keys. The width is remembered for next time, and the content switches to two columns once there is room.

Behavior
Show code
<div class="offcanvas offcanvas-end basalt-drawer" tabindex="-1" id="guide" role="dialog" aria-labelledby="guide-title"
     data-basalt-drawer-resize data-min="320" data-max="880">
  <div class="basalt-drawer-resize" role="separator" aria-orientation="vertical"
       aria-label="Drawer width" tabindex="0"></div>
  <div class="offcanvas-header">…</div>
  <div class="offcanvas-body">…</div>
</div>

Push drawer

A side panel that moves the content over instead of covering it, so both stay usable. Good for folders or filters you keep open while working. Below 768px there is not enough room to share, so it covers the content instead.

Layout
Inbox
  • Elaine ZellerCan the carer come before 8 on Friday?9:40 am
  • Sharon OakleyInvoice #931 paid, thank you8:15 am
  • Brenda GillThe trial went well. Setup only took ten minutes.Mon
  • Tom RoachCould we add Travel Planner to six seats?Sun
Show code
<div class="basalt-push is-open" data-basalt-push>
  <aside class="basalt-push-panel" id="folders" aria-label="Folders">…</aside>
  <div class="basalt-push-main">
    <button type="button" class="btn btn-outline-secondary btn-sm" data-basalt-push-toggle
            aria-controls="folders" aria-expanded="true">Hide folders</button>
    …
  </div>
</div>

Responsive offcanvas

.offcanvas-lg is an ordinary column from 992px up and a drawer below that, opened by a button that only shows on smaller screens. Narrow the window to see it switch.

Layout
Leather Trench CoatSilk Gown DressAftercare BoxBar Loafers
Show code
<button class="btn btn-outline-secondary d-lg-none" type="button" data-bs-toggle="offcanvas"
        data-bs-target="#categories" aria-controls="categories">Show categories</button>

<div class="offcanvas-lg offcanvas-start" tabindex="-1" id="categories" role="region" aria-labelledby="categories-title">
  <div class="offcanvas-header d-lg-none">
    <h2 class="offcanvas-title" id="categories-title">Categories</h2>
    <button type="button" class="btn-close" data-bs-dismiss="offcanvas"
            data-bs-target="#categories" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body">…</div>
</div>

Bottom sheet with snap points

Rises from the bottom to half height and snaps to full when dragged up, the way phone apps do. Drag it down to close. The handle is a button too: Enter toggles the height and the arrow keys move between the stops.

Sheet
Show code
<div class="offcanvas offcanvas-bottom basalt-sheet" tabindex="-1" id="add" role="dialog" aria-labelledby="add-title"
     data-basalt-sheet data-snap="50 92">
  <button type="button" class="basalt-sheet-handle" aria-label="Expand the sheet" aria-expanded="false">
    <span aria-hidden="true"></span>
  </button>
  <div class="offcanvas-header">
    <h2 class="offcanvas-title" id="add-title">Add to the order</h2>
    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body">…</div>
</div>
<!-- data-snap: the stops, as percentages of the window height -->

Filter drawer

Filters live in a drawer so the list keeps its width. Each option shows how many orders it would leave, the footer button counts the result before you commit, and what you applied comes back as chips you can remove one by one.

Drawer

10 orders

  • #9142Arbor North StudioEugene · today · standingPacked$3,894.00
  • #9141The Silk RoomEugene · today · standingAwaiting packing$447.00
  • #9139The Wool ExchangeTacoma · 2 days agoIn transit$2,145.00
  • #9137Hartley & BriarTacoma · 3 days ago · standingPacked$250.00
  • #9133North Shoal MercantileBay Area · 5 days agoOn hold$1,298.00
  • #9130Moss & Mercer Co.Bay Area · 6 days agoAwaiting packing$214.50
  • #9124Saltmarsh OutfittersEugene · 9 days ago · standingIn transit$125.00
  • #9118Wren & Thistle GoodsTacoma · 14 days ago · standingDelivered$595.00
  • #9107Little Moorings GoodsEugene · 21 days ago · standingDelivered$1,180.00
  • #9096Magnolia Lane BoutiqueBay Area · 33 days agoOn hold$392.00
Show code
<div class="offcanvas offcanvas-end basalt-drawer" tabindex="-1" id="filters" role="dialog" aria-labelledby="filters-title">
  <div class="offcanvas-header">
    <div>
      <h2 class="offcanvas-title" id="filters-title">Filter orders</h2>
      <p class="basalt-drawer-sub">Counts update as you choose.</p>
    </div>
    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <form class="basalt-drawer-form">
    <div class="offcanvas-body">
      <fieldset class="basalt-drawer-section">
        <legend class="basalt-drawer-legend">Status</legend>
        <div class="form-check">
          <input class="form-check-input" type="checkbox" id="f-packed" name="status" value="packed">
          <label class="form-check-label" for="f-packed">Packed <span class="basalt-drawer-count">2</span></label>
        </div>
      </fieldset>
    </div>
    <div class="basalt-drawer-foot">
      <button type="reset" class="btn btn-outline-secondary">Reset</button>
      <button type="submit" class="btn btn-primary">Show 10 orders</button>
    </div>
  </form>
</div>

<!-- What was applied, each removable -->
<div class="basalt-applied">
  <span class="basalt-applied-chip">Packed
    <button type="button" aria-label="Remove Packed"><i class="bi bi-x"></i></button>
  </span>
</div>

Record drawer with stepping

Open one record from a list, then step to the next without closing. Previous and next buttons, or Alt with the arrow keys, walk the list, and the row you are on stays marked behind the drawer.

Drawer
Show code
<div class="offcanvas offcanvas-end basalt-drawer basalt-drawer-record" tabindex="-1" id="record" role="dialog" aria-labelledby="record-title">
  <div class="offcanvas-header">
    <h2 class="offcanvas-title" id="record-title">Oakhaven Studio</h2>
    <div class="basalt-drawer-nav">
      <span class="basalt-drawer-pos" aria-live="polite">1 of 5</span>
      <button type="button" class="btn btn-icon" data-basalt-record-prev aria-label="Previous customer"><i class="bi bi-chevron-up"></i></button>
      <button type="button" class="btn btn-icon" data-basalt-record-next aria-label="Next customer"><i class="bi bi-chevron-down"></i></button>
    </div>
    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body">…</div>
</div>

Drill-in drawer

A menu that goes deeper in place. Each level slides in over the last, the header shows where you are with a back button, and focus lands on the first item of every level and returns to the one you came from.

Drawer
Show code
<div class="offcanvas offcanvas-start basalt-drawer" tabindex="-1" id="menu" role="dialog" aria-labelledby="menu-title" data-basalt-drawer-views>
  <div class="offcanvas-header">
    <button type="button" class="btn btn-icon" data-basalt-view-back aria-label="Back" hidden><i class="bi bi-chevron-left"></i></button>
    <h2 class="offcanvas-title" id="menu-title" data-basalt-view-title>Store menu</h2>
    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body basalt-drawer-views">
    <div class="basalt-drawer-views-view" data-view="root" data-title="Store menu">
      <button type="button" class="basalt-drawer-views-item" data-basalt-view-go="devices">Clothing</button>
    </div>
    <div class="basalt-drawer-views-view" data-view="devices" data-title="Clothing" hidden>
      …
    </div>
  </div>
</div>