Dark Mode
How do we detect and set the color scheme?
JavaScript detects the user’s preferred color scheme by checking the prefers-color-scheme media query (either light or dark). Once detected, we store the user’s preference in a cookie so the site can remember it across sessions.
At the CSS level, the script applies two key changes:
It sets the color-scheme property on the :root element:
:root { color-scheme: dark; /* or light, based on user preference */ }It adds a corresponding class to the <body> element:
<body class="theme-dark"> <!-- or "theme-light" -->This class allows for theme-specific styling through CSS. Wherever possible, we use the light-dark() function to define color values that adapt automatically based on the theme. For example:
body { background-color: light-dark(#ffffff, #151515); /* white for light mode, dark gray for dark mode */ color: light-dark(#000000, #f0f0f0); /* black for light mode, near-white for dark mode */ }
CSS
| Element | Standard style | Darkmode style |
|---|---|---|
| WolfPack red | |
|
| Secondary color (gray) | |
|
| Success color (green) | |
|
| Body background color | |
|
| Body font color (every element but h1 and a) | |
|
| Anchor color | |
|
| Anchor color hover | |
|
| Button color | |
|
| Table striping (odd rows) | |
|
| Form input background color | |
|
| Border color | |
|
| Button disabled | |
|
| Accordion color | |
|
Updated