Skip to content

Commit 4ec0456

Browse files
authored
fix: correct matchMedia query in theme toggle (#1082)
The "@media" prefix is invalid inside matchMedia() — it takes a bare media query string. This caused prefersDark to always be false, so the toggle icon defaulted to the light theme regardless of OS preference.
1 parent 22005f5 commit 4ec0456

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs/content/fsdocs-theme-toggle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {LitElement, html, css} from 'https://cdn.jsdelivr.net/gh/lit/dist@3/core/lit-core.min.js';
22

3-
const prefersDark = window.matchMedia("@media (prefers-color-scheme: dark)").matches;
3+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
44
let currentTheme = localStorage.getItem('theme') ?? (prefersDark ? 'dark' : 'light');
55

66
export class ThemeToggle extends LitElement {

0 commit comments

Comments
 (0)