Files
cloud-native-app-initializer/initializer-page/src/components/utils/Theme.js
2022-12-03 00:54:53 +08:00

19 lines
399 B
JavaScript

import {useState} from 'react'
function getTheme() {
const isDarkConfig =
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches
const theme = localStorage.getItem('springtheme')
if (!theme) {
return isDarkConfig ? 'dark' : 'light'
}
return theme
}
export default function useTheme() {
const [darkTheme] = useState(getTheme())
return darkTheme
}