Skip to content
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

Table contextual classes (table-danger etc) do not adapt to dark mode #39272

Open
3 tasks done
Tracked by #2223
Aileron79 opened this issue Oct 4, 2023 · 6 comments
Open
3 tasks done
Tracked by #2223

Comments

@Aileron79
Copy link

Prerequisites

Describe the issue

While alerts perfectly adapt to dark mode and change color accordingly, the contextual table classes (table-danger, table-success, ...) don't - looks kind of ugly, and very bright on a dark background. See screenshot and pen below.

image

Reduced test cases

https://codepen.io/Aileron79/pen/dywgNgY

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.1

@julien-deramond
Copy link
Member

Thanks for opening this issue @Aileron79
Indeed this is not yet functional as mentioned in Tables > Variants

Heads up! Because of the more complicated CSS used to generate our table variants, they most likely won’t see color mode adaptive styling until v6.

@Aileron79
Copy link
Author

Thanks, I did not see that - probably I checked an older version's documentation. Looking forward to v6 then.

@pragyamishra56

This comment was marked as off-topic.

@emmahsax
Copy link

emmahsax commented Dec 11, 2023

I'm not sure if my issue is what the comment in the docs means, but when I upgraded to v5.3.2, my tables (using the default variant), no longer change color at all based on the computer's color mode changing. It's like the default variant (no table-X class at all), just is the light mode 100% of the time.

I did get as far into debugging to learn that the CSS works as I expect in v5.3.0-alpha3, but then it starts to break in v5.3.0, and continues to be broken up until v5.3.2. Maybe this helps?

The only way I found to workaround this is to put this in my CSS, and then change that color based on color mode:

.table {
  --bs-table-bg: #000000;
}

But the strange thing is their docs (found here) do have the default variant changing based on the system's mode changing. Even just copy-pasting their basic table example doesn't work:

  • Literally copy-pasted this block into my page:
<table class="table">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">First</th>
      <th scope="col">Last</th>
      <th scope="col">Handle</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
  • Dark mode:
    image
  • Light mode:
    image

@julien-deramond
Copy link
Member

@emmahsax I'm not sure to understand what the issue is here. I've created https://codepen.io/julien-deramond/pen/NWomqGo with the basic example you've copied and it works both with light and dark mode (by using data-bs-theme).

Since it doesn't seem to be related to the variants, could you please create first a Q&A Discussion with maybe a CodePen in it? It seems to be rather a usage issue than a bug.

@emmahsax
Copy link

emmahsax commented Dec 11, 2023

I agree it is a usage issue, since it seems to work on your codepen and in their docs. But I will start a Q&A discussion.

EDIT: https://github.com/orgs/twbs/discussions/39482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants