]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix and add doc
authorlouismaxime.piton <louismaxime.piton@orange.com>
Fri, 15 Sep 2023 13:37:36 +0000 (15:37 +0200)
committerlouismaxime.piton <louismaxime.piton@orange.com>
Fri, 15 Sep 2023 13:37:36 +0000 (15:37 +0200)
site/content/docs/5.3/customize/color-modes.md
site/content/docs/5.3/customize/css-variables.md

index 945d5ec336c09b7027f9e6bbc021a7a43ef250fe..0202532c83ee4944fee87a9d677fcc7b401ee5ac 100644 (file)
@@ -177,6 +177,53 @@ For example, you can create a "blue theme" with the selector `data-bs-theme="blu
 </div>
 ```
 
+## Always go back to main theme
+
+{{< added-in "5.3.3" >}}
+
+Always have your components branded with the main theme of your page by using `data-bs-theme="body"`. If your custom themes were built on top of `color-mode()` mixin, this _back-to-root_ effect will also affect your custom themes.
+
+Here is an example on a light themed navbar with `data-bs-theme="body` on top of the `.dropdown-menu`.
+
+{{< example >}}
+<nav class="navbar navbar-expand-lg bg-body-tertiary" data-bs-theme="light">
+  <div class="container-fluid">
+    <a class="navbar-brand" href="#">Navbar</a>
+    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
+      <span class="navbar-toggler-icon"></span>
+    </button>
+    <div class="collapse navbar-collapse" id="navbarToggle">
+      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
+        <li class="nav-item">
+          <a class="nav-link active" aria-current="page" href="#">Home</a>
+        </li>
+        <li class="nav-item">
+          <a class="nav-link" href="#">Link</a>
+        </li>
+        <li class="nav-item dropdown">
+          <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+            Dropdown
+          </a>
+          <ul class="dropdown-menu" data-bs-theme="body">
+            <li><a class="dropdown-item" href="#">Action</a></li>
+            <li><a class="dropdown-item" href="#">Another action</a></li>
+            <li><hr class="dropdown-divider"></li>
+            <li><a class="dropdown-item" href="#">Something else here</a></li>
+          </ul>
+        </li>
+        <li class="nav-item">
+          <a class="nav-link disabled" aria-disabled="true">Disabled</a>
+        </li>
+      </ul>
+      <form class="d-flex" role="search">
+        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
+        <button class="btn btn-outline-success" type="submit">Search</button>
+      </form>
+    </div>
+  </div>
+</nav>
+{{< /example >}}
+
 ## JavaScript
 
 To allow visitors or users to toggle color modes, you'll need to create a toggle element to control the `data-bs-theme` attribute on the root element, `<html>`. We've built a toggler in our documentation that initially defers to a user's current system color mode, but provides an option to override that and pick a specific color mode.
index ffb40c0c4a4a014c6dc33fb888199b068a7c467a..7dd0454125c7cfbad87064fedd11e9e9e68ec64f 100644 (file)
@@ -21,7 +21,7 @@ These CSS variables are available everywhere, regardless of color mode.
 ```css
 {{< root.inline >}}
 {{- $css := readFile "dist/css/bootstrap.css" -}}
-{{- $match := findRE `:root,\n\[data-bs-theme=light\] {([^}]*)}` $css 1 -}}
+{{- $match := findRE `:root,\n:root\[data-bs-theme=light\] \[data-bs-theme=body\],\n\[data-bs-theme=light\] {([^}]*)}` $css 1 -}}
 
 {{- if (eq (len $match) 0) -}}
 {{- errorf "Got no matches for :root in %q!" $.Page.Path -}}