Movatterモバイル変換


[0]ホーム

URL:


Framework:


Hire UsGet CoreUI PRO all-access

React Offcanvas Component

Offcanvas

React alert component allows build hidden sidebars into your project for navigation, shopping carts.

Other Frameworks

CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.

Examples#

Offcanvas components#

Below is an offcanvas example that is shown by default (viavisible={true}). Offcanvas includes support for a header with a close button and an optional body class for some initialpadding. We suggest that you include offcanvas headers with dismiss actions whenever possible, or provide an explicit dismiss action.

Offcanvas
Content for the offcanvas goes here. You can place just about any React component or custom elements here.

Live demo#

Use the buttons below to show and hide an offcanvas component.

  • visible={false} hides content (default)
  • visible orvisible={true} shows content
Offcanvas
Content for the offcanvas goes here. You can place just about any React component or custom elements here.

Body scrolling#

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

Offcanvas with body scrolling
Try scrolling the rest of the page to see this option in action.

Body scrolling and backdrop#

You can also enable<body> scrolling with a visible backdrop.

Backdrop with scrolling
Try scrolling the rest of the page to see this option in action.

Static backdrop#

If you set abackdrop tostatic, your React offcanvas component will not close when clicking outside of it.

Backdrop with scrolling
Try scrolling the rest of the page to see this option in action.

Dark offcanvas#

Change the appearance of offcanvases withdark boolean property to better match them to different contexts like dark navbars.

Offcanvas
Content for the offcanvas goes here. You can place just about any React component or custom elements here.

Responsive#

Responsive offcanvas properties hide content outside the viewport from a specified breakpoint and down.Above that breakpoint, the contents within will behave as usual.For example,responsive="lg" hides content in an offcanvas below the lg breakpoint, but shows the content above the lg breakpoint.

Resize your browser to show the responsive offcanvas toggle.
Responsive offcanvas
This is content within an.offcanvas-lg.

Placement#

There's no default placement for offcanvas components, so you must add one of the modifier classes below;

  • placement="start" places offcanvas on the left of the viewport (shown above)
  • placement="end" places offcanvas on the right of the viewport
  • placement="top" places offcanvas on the top of the viewport
  • placement="bottom" places offcanvas on the bottom of the viewport

Try the top, right, and bottom examples out below.

Offcanvas
Content for the offcanvas goes here. You can place just about any React component or custom elements here.
Offcanvas
Content for the offcanvas goes here. You can place just about any React component or custom elements here.
Offcanvas
Content for the offcanvas goes here. You can place just about any React component or custom elements here.

Accessibility#

Since the offcanvas panel is conceptually a modal dialog, be sure to addaria-labelledby="..."—referencing the offcanvas title—to<COffcanvas>. Note that you don’t need to addrole="dialog" since we already add it automatically.

API#

Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.

CoreUI for React is Open Source UI Components Library for React.js.

CoreUI code licensedMIT, docsCC BY 3.0. CoreUI PRO requires acommercial license.


[8]ページ先頭

©2009-2025 Movatter.jp