Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #32090 #32094

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions site/docs/4.5/components/navbar.md
Expand Up @@ -19,8 +19,6 @@ Here's what you need to know before getting started with the navbar:

{% include callout-info-prefersreducedmotion.md %}

Read on for an example and list of supported sub-components.

## Supported content

Navbars come with built-in support for a handful of sub-components. Choose from the following as needed:
Expand Down Expand Up @@ -77,7 +75,7 @@ This example uses [color]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilit

### Brand

The `.navbar-brand` can be applied to most elements, but an anchor works best as some elements might require utility classes or custom styles.
The `.navbar-brand` can be applied to most elements, but an anchor works best, as some elements might require utility classes or custom styles.

{% capture example %}
<!-- As a link -->
Expand Down Expand Up @@ -167,7 +165,7 @@ And because we use classes for our navs, you can avoid the list-based approach e
{% endcapture %}
{% include example.html content=example %}

You may also utilize dropdowns in your navbar nav. Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for `.nav-item` and `.nav-link` as shown below.
You can also use dropdowns in your navbar. Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for `.nav-item` and `.nav-link` as shown below.

{% capture example %}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
Expand Down Expand Up @@ -216,7 +214,7 @@ Place various form controls and components within a navbar with `.form-inline`.
{% endcapture %}
{% include example.html content=example %}

Immediate children elements in `.navbar` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/) as needed to adjust this behavior.
Immediate child elements of `.navbar` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/) as needed to adjust this behavior.

{% capture example %}
<nav class="navbar navbar-light bg-light">
Expand Down Expand Up @@ -404,7 +402,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl

## Containers

Although it's not required, you can wrap a navbar in a `.container` to center it on a page or add one within to only center the contents of a [fixed or static top navbar](#placement).
Although it's not required, you can wrap a navbar in a `.container` to center it on a page. Or you can add a container inside the `.navbar` to only center the contents of a [fixed or static top navbar](#placement).

{% capture example %}
<div class="container">
Expand Down Expand Up @@ -462,15 +460,15 @@ Also note that **`.sticky-top` uses `position: sticky`, which [isn't fully suppo

## Responsive behaviors

Navbars can utilize `.navbar-toggler`, `.navbar-collapse`, and `.navbar-expand{-sm|-md|-lg|-xl}` classes to change when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements.
Navbars can use `.navbar-toggler`, `.navbar-collapse`, and `.navbar-expand{-sm|-md|-lg|-xl}` classes to determine when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements.

For navbars that never collapse, add the `.navbar-expand` class on the navbar. For navbars that always collapse, don't add any `.navbar-expand` class.

### Toggler

Navbar togglers are left-aligned by default, but should they follow a sibling element like a `.navbar-brand`, they'll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.

With no `.navbar-brand` shown in lowest breakpoint:
With no `.navbar-brand` shown at the smallest breakpoint:

{% capture example %}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
Expand Down Expand Up @@ -561,7 +559,7 @@ With a toggler on the left and brand name on the right:

### External content

Sometimes you want to use the collapse plugin to trigger hidden content elsewhere on the page. Because our plugin works on the `id` and `data-target` matching, that's easily done!
Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the `.navbar` . Because our plugin works on the `id` and `data-target` matching, that's easily done!

{% capture example %}
<div class="fixed-top">
Expand All @@ -579,3 +577,5 @@ Sometimes you want to use the collapse plugin to trigger hidden content elsewher
</div>
{% endcapture %}
{% include example.html content=example %}

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.