Bootstrap 5.3 introduced the dark color scheme and we added support for it in all our components.
Use the data-bs-theme="dark"
attribute on the <html>
element to enable it.
See the Bootstrap Dark mode documentation for more details.
<!doctype html>
<html lang="en" data-bs-theme="dark">
<!-- ... -->
</html>
auto
color mode built-in in Bootstrap 5.3.window.matchMedia('(prefers-color-scheme: dark)').matches
query to detect the user's preference on startup and set the color mode accordingly.
The color mode switcher has to be implemented with the help of JavaScript.
You can use the script written by Bootstrap to do the job.
If you want to integrate the color mode switcher into your Blazor application and support server-side prerendering, you can take a look at
the implementation of DocColorModeSwitcher
used for this documentation.
PersistentComponentState
to pass the prerendered color mode to the Blazor WebAssembly client.IDocColorModeResolver
to resolve the color mode on the server and client.auto
mode only resolves when the application starts.