@serendie/ui
Version:
Adaptive UI component library as part of Serendie Design System by Mitsubishi Electric
20 lines (19 loc) • 508 B
JavaScript
import { useSyncExternalStore as t } from "react";
function n() {
return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
function o(e) {
const r = window.matchMedia("(prefers-color-scheme: dark)");
return r.addEventListener("change", e), () => r.removeEventListener("change", e);
}
function c() {
return t(
o,
n,
() => "light"
// サーバー側のスナップショット
);
}
export {
c as useSystemColorScheme
};