mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 18:36:21 +00:00
feat(navbar) a navbar with theme switcher
This commit is contained in:
1 parent
65e7c101ac
commit
d26d45c65a
7 files changed
+139
-11
No files matched your search
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user