Skip to content

Commit f08b0df

Browse files
techfgdelucis
andauthored
fix: respond to media query change events when theme is auto (#1731)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
1 parent f264730 commit f08b0df

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

‎.changeset/swift-files-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/starlight': patch
3+
---
4+
5+
Fixes responding to system color scheme changes when theme is `auto`

‎packages/starlight/components/ThemeSelect.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ const { labels } = Astro.props;
4242
this.#onThemeChange(this.#parseTheme(e.currentTarget.value));
4343
}
4444
});
45+
matchMedia(`(prefers-color-scheme: light)`).addEventListener('change', () => {
46+
if (this.#loadTheme() === 'auto') this.#onThemeChange('auto');
47+
});
4548
}
4649
}
4750

0 commit comments

Comments
 (0)