-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
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
data-bs-theme="dark" behaves differently compared to CSS class navbar-dark
#38973
Comments
Thanks for reporting this issue @nenadvicentic. This is probably just a reduced test case but if you add |
@julien-deramond The problem with your solution is that it breaks intended light/dark mode behavior. I am not sure if codepen examples can attach HTML attribute to Original approach with Update I managed to toggle |
@julien-deramond Thank you for this very useful and clear reply. Yes, you hit my use case straight to the point. I think the main confusion comes from the fact that two different concepts of "dark" are now mixed together. From my point of view It is easiest to explain on buttons example from the documentation: In the auto/light mode and Bootstrap versions preceding 5.3, they look like this: Text color in buttons switches from white to black, calculated based on If we switch page to the
We both wanted do achieve same behavior with a navbar. When we assign color to a navbar, for example So, how I see this, <nav class="navbar bg-primary text-contrast" aria-label="Top Navigation Bar">
</nav>
<nav class="navbar bg-secondary text-contrast" aria-label="Top Navigation Bar">
</nav>
<nav class="navbar bg-warning text-contrast" aria-label="Top Navigation Bar">
</nav>
<nav class="navbar bg-info text-contrast" aria-label="Top Navigation Bar">
</nav> If this is not feasible perhaps simpler to understand option would be to introduce <nav class="navbar bg-primary btn-text-primary" aria-label="Top Navigation Bar">
</nav>
<nav class="navbar bg-secondary btn-text-secondary " aria-label="Top Navigation Bar">
</nav>
<nav class="navbar bg-warning btn-text-warning " aria-label="Top Navigation Bar">
</nav>
<nav class="navbar bg-info btn-text-info " aria-label="Top Navigation Bar">
</nav> From my point of view, it is important not to mix concepts of text contrast and light/dark modes. And I think that recommending to use |
I just came across this issue when changing the background color for navbars.
someone clever could probably update the SASS rules so this happens automaticlly the same as |
When setting I switched it to navbar-dark and the collapse icon showed again in the way you would expect. |
Prerequisites
Describe the issue
When we want to have a navbar using
bg-primary
and need to make text inside of navbar white (bg-body), we could use:In that case, dropdowns have white background with default text color, like the page itself.

With the new recommendation, starting with version 5.3, we should replace
navbar-dark
withdata-bs-theme="dark"
:While navbar itself looks identical, this turns dropdowns and input boxes inside of dropdown in the "dark" mode (black background and light text, while everything else on the page is still white background and black text).

The problem is that currently there is no way to make dropdown use default background and text colors, while navbar is "dark".
Culprit for this behavior is this rule:
Reduced test cases
Codepen for
navbar-dark
: https://codepen.io/nenadvicentic/pen/LYXgvVXCodepen for (broken)
data-bs-theme="dark"
: https://codepen.io/nenadvicentic/pen/XWyxoaBWhat operating system(s) are you seeing the problem on?
Windows
What browser(s) are you seeing the problem on?
Chrome, Firefox
What version of Bootstrap are you using?
5.3.0
The text was updated successfully, but these errors were encountered: