Skip to content

Commit 8eab7b1

Browse files
committed
✨ Update meta tag theme colors when switching themes
1 parent 419a907 commit 8eab7b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/App.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ function App() {
1818
setSelectedTheme(theme);
1919
}, [themeLoaded]);
2020

21+
useEffect(() => {
22+
if (document) {
23+
document!
24+
.querySelector('meta[name="theme-color"]')!
25+
.setAttribute("content", theme.colors.body);
26+
document!
27+
.querySelector('meta[name="msapplication-TileColor"]')!
28+
.setAttribute("content", theme.colors.body);
29+
document!
30+
.querySelector('link[rel="mask-icon"]')!
31+
.setAttribute("color", theme.colors.body);
32+
}
33+
}, [selectedTheme]);
34+
2135
const themeSwitcher = (switchTheme: Theme) => {
2236
setSelectedTheme(switchTheme);
2337
setMode(switchTheme);

0 commit comments

Comments
 (0)