-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Potential for contrast issues with '.btn-close' class #39765
Comments
As you said, using As a temporary solution, you'll probably need to override the rendering yourself with some CSS custom code. Something like this https://codepen.io/julien-deramond/pen/LYvGqLX could help, even if there are probably more elegant solutions: <div class="container py-5 gap-3 d-flex flex-column w-100 h-100 bg-body" data-bs-theme="dark">
<div class="toast fade show text-body" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header text-dark bg-warning" data-bs-theme="light">
<svg class="bd-placeholder-img rounded me-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false">
<rect width="100%" height="100%" fill="#007aff"></rect>
</svg>
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
</div> [data-bs-theme="light"].toast-header .btn-close {
filter: invert(0) grayscale(100%) brightness(200%);
} |
Thanks! I was able to work around it - it's a bit hacky, but I made a class that only applies to my dark theme: // dark theme close button work-around (for light-coloured elements in dark mode)
// Refer to: https://github.com/twbs/bootstrap/issues/39765
.btn-close-dark {
@extend .btn-close;
--bs-btn-close-white-filter: invert(0) !important;
} Then on my elements where I need it, I just set Is there a better way to do it? Probably... but it works so that's good enough for me lol |
Prerequisites
Describe the issue
As of Bootstrap 5.3, we have lost the ".btn-close-white" class. In theory, this seems fine since the flip is now handled by the new "dark mode" implementation, however it can present and issue if the button is placed over an element of similar lightness.
Take for example, the following:
Under the light theme everything looks okay, however as soon as you flip to the dark theme the X switches to the lighter colour and becomes difficult to see:
I realize I could manually set the data-bs-theme on the button to force it to stay with the light theme, but that's more of a workaround.This is not necessarily true depending on how and when you call in your theme, I think? It worked in my code pen, but not on the site that I'm working on.Disclaimer:
I am incredibly new to SASS, so:
Reduced test cases
Codepen Demo
What operating system(s) are you seeing the problem on?
Windows
What browser(s) are you seeing the problem on?
Chrome
What version of Bootstrap are you using?
5.3.2
The text was updated successfully, but these errors were encountered: