mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-01-29 21:49:35 +00:00
33 lines
894 B
TypeScript
33 lines
894 B
TypeScript
import DarkModeRoundedIcon from '@mui/icons-material/DarkModeRounded';
|
|
import LightModeRoundedIcon from '@mui/icons-material/LightModeRounded';
|
|
import { IconButton,useColorScheme } from '@/lib/mui';
|
|
import React from 'react';
|
|
|
|
export default function ColorSchemeToggle() {
|
|
const { mode, setMode } = useColorScheme();
|
|
const [mounted, setMounted] = React.useState(false);
|
|
React.useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
if (!mounted) {
|
|
return <IconButton size="sm" variant="outlined" color="primary" />;
|
|
}
|
|
return (
|
|
<IconButton
|
|
id="toggle-mode"
|
|
size="sm"
|
|
variant="outlined"
|
|
color="primary"
|
|
onClick={() => {
|
|
if (mode === 'light') {
|
|
setMode('dark');
|
|
} else {
|
|
setMode('light');
|
|
}
|
|
}}
|
|
>
|
|
{mode === 'light' ? <DarkModeRoundedIcon /> : <LightModeRoundedIcon />}
|
|
</IconButton>
|
|
);
|
|
}
|