Nearby lessons

29 of 39

πŸ“‚ BS5 Offcanvas

πŸ“Œ What Is Bootstrap 5 Offcanvas?

Offcanvas is a panel that slides in from an edge (sidebar, cart, filters). Use .offcanvas with a position class, an id, and .offcanvas-header / .offcanvas-body. Trigger: data-bs-toggle="offcanvas" and data-bs-target="#offcanvasId". Requires Bootstrap’s JavaScript.

πŸ“‚ Offcanvas Structure (.offcanvas, .offcanvas-header, .offcanvas-body)

.offcanvas – panel wrapper. .offcanvas-header – top bar with .offcanvas-title and .btn-close (data-bs-dismiss="offcanvas"). .offcanvas-body – main content. Give the offcanvas an id for the trigger.

πŸ…±οΈ

bootstrap Designer

Live Component Playground

html Source
Loading...
Built with Bootstrap 5.3 β€’ Enterprise Ready

πŸ“ Position (.offcanvas-start, .offcanvas-end, .offcanvas-top, .offcanvas-bottom)

.offcanvas-start – slides from the left. .offcanvas-end – from the right. .offcanvas-top – from the top. .offcanvas-bottom – from the bottom. Add one to the same element as .offcanvas.

πŸ…±οΈ

bootstrap Designer

Live Component Playground

html Source
Loading...
Built with Bootstrap 5.3 β€’ Enterprise Ready

βœ… Offcanvas Best Practices

  • Use data-bs-toggle="offcanvas" and data-bs-target="#id" on the trigger.
  • Use .offcanvas-start or .offcanvas-end for side panels.
  • Close button: .btn-close with data-bs-dismiss="offcanvas".

🧠 Test Your Knowledge

3 Questions

Progress: 0 / 3
Keep Going!BS5 Utilities