diff --git a/scss/_navbar.scss b/scss/_navbar.scss index 2ccef11b7c..a395ede659 100644 --- a/scss/_navbar.scss +++ b/scss/_navbar.scss @@ -193,13 +193,42 @@ .navbar-toggler { display: none; } + + .offcanvas-header { + display: none; + } + + .offcanvas { + position: inherit; + bottom: 0; + z-index: 1000; + flex-grow: 1; + visibility: visible !important; /* stylelint-disable-line declaration-no-important */ + background-color: transparent; + border-right: 0; + border-left: 0; + @include transition(none); + transform: none; + } + .offcanvas-top, + .offcanvas-bottom { + height: auto; + border-top: 0; + border-bottom: 0; + } + + .offcanvas-body { + display: flex; + flex-grow: 0; + padding: 0; + overflow-y: visible; + } } } } } // scss-docs-end navbar-expand-loop - // Navbar themes // // Styles for switching between navbars with light or dark background. diff --git a/site/content/docs/5.0/components/navbar.md b/site/content/docs/5.0/components/navbar.md index 7b57fd5c62..1abfcd16c2 100644 --- a/site/content/docs/5.0/components/navbar.md +++ b/site/content/docs/5.0/components/navbar.md @@ -655,6 +655,70 @@ Sometimes you want to use the collapse plugin to trigger a container element for When you do this, we recommend including additional JavaScript to move the focus programmatically to the container when it is opened. Otherwise, keyboard users and users of assistive technologies will likely have a hard time finding the newly revealed content - particularly if the container that was opened comes *before* the toggler in the document's structure. We also recommend making sure that the toggler has the `aria-controls` attribute, pointing to the `id` of the content container. In theory, this allows assistive technology users to jump directly from the toggler to the container it controls–but support for this is currently quite patchy. +### Offcanvas + +Transform your expanding and collapsing navbar into an offcanvas drawer with the offcanvas plugin. We extend both the offcanvas default styles and use our `.navbar-expand-*` classes to create a dynamic and flexible navigation sidebar. + +In the example below, to create an offcanvas navbar that is always collapsed across all breakpoints, omit the `.navbar-expand-*` class entirely. + +{{< example >}} + +{{< /example >}} + +To create an offcanvas navbar that expands into a normal navbar at a specific breakpoint like `lg`, use `.navbar-expand-lg`. + +```html + +``` + ## Sass ### Variables