Hello ![]()
I’ve added data-color-scheme to the #d-splash section, so you can easily set up light and dark scheme splash logos. DEV: Implement dynamic color scheme for splash section · VaperinaDEV/custom-splash-html-builder@ba6641b · GitHub
<%- splash_forced_scheme = (dark_color_scheme? || forced_dark_mode?) ? "dark" : (forced_light_mode? ? "light" : nil) %>
<section id="d-splash"<%= " data-color-scheme=\"#{splash_forced_scheme}\"".html_safe if splash_forced_scheme %>>
So #d-splash gets a data-color-scheme="dark" / "light" attribute when a light or dark scheme is explicitly forced, and is left without the attribute only when both schemes are enabled and the OS is meant to decide.
The fix is to let that attribute take priority over the media query in the custom CSS, and only fall back to prefers-color-scheme when the attribute is absent.
Example:
Custom HTML
<!-- LIGHT MODE -->
<div class="custom-splash-light">
<div class="ring-layer">
<svg viewBox="0 0 500 500">
...
</svg>
</div>
<div class="logo-layer">
<svg viewBox="0 0 500 500">
...
</svg>
</div>
</div>
<!-- DARK MODE -->
<div class="custom-splash-dark">
<div class="ring-layer">
<svg viewBox="0 0 500 500">
...
</svg>
</div>
<div class="logo-layer">
<svg viewBox="0 0 500 500">
...
</svg>
</div>
</div>
Custom CSS
#d-splash .custom-splash-dark {
display: none;
}
/* OS decides — only when there's no forced scheme */
@media (prefers-color-scheme: dark) {
#d-splash:not([data-color-scheme]) .custom-splash-light {
display: none;
}
#d-splash:not([data-color-scheme]) .custom-splash-dark {
display: block;
}
}
/* forced scheme always wins, regardless of OS */
#d-splash[data-color-scheme="light"] .custom-splash-dark {
display: none;
}
#d-splash[data-color-scheme="dark"] .custom-splash-light {
display: none;
}
#d-splash[data-color-scheme="dark"] .custom-splash-dark {
display: block;
}
Since :not([data-color-scheme]) simply doesn’t match once the attribute is present, there’s no specificity fight between the two rule sets, the forced scheme always wins.