Files
vantage-app/site/components/ThemeScript.tsx
T
2026-07-22 16:50:13 +01:00

17 lines
468 B
TypeScript

// Applies the stored theme before first paint. Without this the page renders in
// the OS theme for a frame and then snaps to the stored one.
const script = `
(function(){
try {
var t = localStorage.getItem("vantage-theme");
if (t === "light" || t === "dark") {
document.documentElement.setAttribute("data-theme", t);
}
} catch (e) {}
})();
`;
export function ThemeScript() {
return <script dangerouslySetInnerHTML={{ __html: script }} />;
}