In the latest version of Bootstrap, 5.3, users have the ability to select a theme for their websites. The built-in options include a Dark theme and a Light theme.
For instance, by setting
<html data-bs-theme="dark">
, you can specify that the navbar should have a light color. Conversely, if you set <html data-bs-theme="light">
, you may want the navbar to display dark background colors.
Is there a specific Bootstrap class that can be utilized to automatically switch the colors based on the selected theme?
Experimenting with the body-*
classes did not yield the desired results. I am looking for a way to toggle between the opposite of the current text-body
or bg-body
colors.
<nav class="navbar text-body bg-body">
</nav>
How can I invert the background color based on the chosen light/dark theme in Bootstrap 5.3?