Skip to content

Potential for contrast issues with '.btn-close' class #39765

@abraxas86

Description

@abraxas86

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:

<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
  <div class="toast-header bg-warning">
    <img src="..." class="rounded me-2" alt="...">
    <strong class="me-auto">Warning!</strong>
    <small>11 mins ago</small>
    <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  </div>
  <div class="toast-body">
    This is a warning message.
  </div>
</div>

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:

LightDark

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:

  1. I have no idea if this can be extended like many of the other classes can be.
  2. It is entirely possible that the problem is between the chair and the keyboard here 😅

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions