跳到主要内容

Offcanvas

Build hidden sidebars into your project for navigation, shopping carts, and more.

Examples

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.

Basic Example

结果
Loading...
实时编辑器

Responsive

Responsive offcanvas classes hide content outside the viewport from a specified breakpoint and down. Above that breakpoint, the contents within will behave as usual.

结果
Loading...
实时编辑器

Placement

Offcanvas supports a few different placements:

  • start places offcanvas on the left of the viewport
  • end places offcanvas on the right of the viewport
  • top places offcanvas on the top of the viewport
  • bottom places offcanvas on the bottom of the viewport
结果
Loading...
实时编辑器

Backdrop

Scrolling the <body> element is disabled when an offcanvas and its backdrop are visible. Use the scroll prop to toggle <body> scrolling and the backdrop prop to toggle the backdrop.

结果
Loading...
实时编辑器

Static backdrop

When backdrop is set to static, the offcanvas will not close when clicking outside of it.

结果
Loading...
实时编辑器

API

Offcanvas

OffcanvasHeader

OffcanvasTitle

OffcanvasBody