summaryrefslogtreecommitdiff
path: root/examples/docs/public/theme.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/docs/public/theme.js')
-rw-r--r--examples/docs/public/theme.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/docs/public/theme.js b/examples/docs/public/theme.js
new file mode 100644
index 000000000..d75d0bf99
--- /dev/null
+++ b/examples/docs/public/theme.js
@@ -0,0 +1,8 @@
+(() => {
+ const root = document.documentElement;
+ if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
+ root.classList.add('theme-dark');
+ } else {
+ root.classList.remove('theme-dark');
+ }
+})();