Skip to content

Commit

Permalink
Add data attr selector for dark mode navbars (#38522)
Browse files Browse the repository at this point in the history
* Add data attr selector for dark mode navbars

* Fix dark example
  • Loading branch information
mdo authored May 19, 2023
1 parent e87852f commit a6dc107
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion scss/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@
@include deprecate("`.navbar-light`", "v5.2.0", "v6.0.0", true);
}

.navbar-dark {
.navbar-dark,
.navbar[data-bs-theme="dark"] {
// scss-docs-start navbar-dark-css-vars
--#{$prefix}navbar-color: #{$navbar-dark-color};
--#{$prefix}navbar-hover-color: #{$navbar-dark-hover-color};
Expand Down
6 changes: 3 additions & 3 deletions site/content/docs/5.3/components/navbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ Mix and match with other components and utilities as needed.
**New in v5.2.0 —** Navbar theming is now powered by CSS variables and `.navbar-light` has been deprecated. CSS variables are applied to `.navbar`, defaulting to the "light" appearance, and can be overridden with `.navbar-dark`.
{{< /callout >}}

Navbar themes are easier than ever thanks to Bootstrap's combination of Sass and CSS variables. The default is our "light navbar" for use with light background colors, but you can also apply `data-bs-theme="dark"` to the `.navbar` parent for dark background colors. Then, customize with `.bg-*` utilities.
Navbar themes are easier than ever thanks to Bootstrap's combination of Sass and CSS variables. The default is our "light navbar" for use with light background colors, but you can also apply `data-bs-theme="dark"` to the `.navbar` parent for dark background colors. Then, customize with `.bg-*` and additional utilities.

<div class="bd-example">
<nav class="navbar navbar-expand-lg bg-body-secondary" data-bs-theme="dark">
<nav class="navbar navbar-expand-lg bg-dark border-bottom border-bottom-dark" data-bs-theme="dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
Expand Down Expand Up @@ -420,7 +420,7 @@ Navbar themes are easier than ever thanks to Bootstrap's combination of Sass and
</div>

```html
<nav class="navbar bg-dark" data-bs-theme="dark">
<nav class="navbar bg-dark border-bottom border-bottom-dark" data-bs-theme="dark">
<!-- Navbar content -->
</nav>

Expand Down

0 comments on commit a6dc107

Please sign in to comment.