feat(navbar) a navbar with theme switcher

This commit is contained in:
lumither committed 2024-04-25 00:41:32 +08:00
1 parent 65e7c101ac
commit d26d45c65a
7 files changed
+139 -11

No files matched your search

+14 -7
View File
@@ -2,7 +2,8 @@
import React, { useEffect, useState } from 'react';
import { useTheme } from 'next-themes';
import { Button } from '@nextui-org/react';
import { Switch } from '@nextui-org/react';
import { MdOutlineDarkMode, MdOutlineLightMode } from 'react-icons/md';
function ThemeSwitcher() {
const [ mounted, setMounted ] = useState(false);
@@ -18,12 +19,18 @@ function ThemeSwitcher() {
return (
<div>
<Button onClick={ () => {
setTheme('light');
} }>Light Mode</Button>
<Button onClick={ () => {
setTheme('dark');
} }>Dark Mode</Button>
<Switch
color={ 'default' }
startContent={ <MdOutlineLightMode /> }
endContent={ <MdOutlineDarkMode /> }
onValueChange={ (isSelected) => {
if (isSelected) {
setTheme('light');
} else {
setTheme('dark');
}
} }
></Switch>
</div>
);
}