diff --git a/dev/index.html b/dev/index.html
index e76e076b..2a89f1ad 100644
--- a/dev/index.html
+++ b/dev/index.html
@@ -4,6 +4,13 @@
SciReactUI Dev
+
+
diff --git a/dev/src/main.tsx b/dev/src/main.tsx
index f5d6adea..bf7de4b1 100644
--- a/dev/src/main.tsx
+++ b/dev/src/main.tsx
@@ -1,9 +1,13 @@
import * as React from "react";
import * as ReactDOM from "react-dom/client";
+
+import { InitColorSchemeScript } from "@mui/material";
+
import App from "./App";
ReactDOM.createRoot(document.getElementById("root")!).render(
+
,
);
diff --git a/src/components/controls/ColourSchemeButton.tsx b/src/components/controls/ColourSchemeButton.tsx
index 68c97dfc..2d3c6141 100644
--- a/src/components/controls/ColourSchemeButton.tsx
+++ b/src/components/controls/ColourSchemeButton.tsx
@@ -1,4 +1,4 @@
-import { IconButton, IconButtonProps } from "@mui/material";
+import { GlobalStyles, IconButton, IconButtonProps } from "@mui/material";
import { useColorScheme } from "@mui/material/styles";
import LightModeIcon from "@mui/icons-material/LightMode";
import BedtimeIcon from "@mui/icons-material/Bedtime";
@@ -7,30 +7,51 @@ export const ColourSchemeButton = (props: IconButtonProps) => {
const { mode, systemMode, setMode } = useColorScheme();
const resolvedMode = mode === "system" ? systemMode : mode;
+ const isReady = resolvedMode === "light" || resolvedMode === "dark";
const isDark = resolvedMode === "dark";
return (
- {
- setMode(isDark ? "light" : "dark");
- props.onClick?.(event);
- }}
- sx={(theme) => ({
- ml: 1,
- width: 32,
- height: 32,
- borderRadius: 1,
- backgroundColor: theme.palette.surface.strong,
- color: theme.palette.text.primary,
- "&:hover": {
+ <>
+
+
+ {
+ document.documentElement.classList.add("ds-mode-changing");
+
+ setMode(isDark ? "light" : "dark");
+
+ window.setTimeout(() => {
+ document.documentElement.classList.remove("ds-mode-changing");
+ }, 250);
+
+ props.onClick?.(event);
+ }}
+ sx={(theme) => ({
+ ml: 1,
+ width: 32,
+ height: 32,
+ borderRadius: 1,
backgroundColor: theme.palette.surface.strong,
- borderColor: theme.palette.border.subtle,
- },
- })}
- >
- {isDark ? : }
-
+ color: theme.palette.text.primary,
+ "&:hover": {
+ backgroundColor: theme.palette.surface.strong,
+ borderColor: theme.palette.border.subtle,
+ },
+ })}
+ >
+ {isReady ? isDark ? : : null}
+
+ >
);
};