Add a dark mode
This commit is contained in:
parent
07c7e63ee7
commit
0325139461
12 changed files with 199 additions and 35 deletions
|
|
@ -25,6 +25,16 @@
|
|||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<script>
|
||||
// Apply theme before render to prevent flash
|
||||
(function () {
|
||||
const stored = localStorage.getItem("theme");
|
||||
const theme =
|
||||
stored ||
|
||||
(window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
||||
document.documentElement.setAttribute("data-bs-theme", theme);
|
||||
})();
|
||||
</script>
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue