mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 18:36:21 +00:00
feat(theme) add ThemeSwitcher.tsx
This commit is contained in:
1 parent
0f415e7bf7
commit
83365be90b
7 files changed
+102
-32
No files matched your search
@@ -0,0 +1,31 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { Button } from '@nextui-org/react';
|
||||
|
||||
function ThemeSwitcher() {
|
||||
const [ mounted, setMounted ] = useState(false);
|
||||
const { theme, setTheme, themes } = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
if (!mounted) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button onClick={ () => {
|
||||
setTheme('light');
|
||||
} }>Light Mode</Button>
|
||||
<Button onClick={ () => {
|
||||
setTheme('dark');
|
||||
} }>Dark Mode</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ThemeSwitcher;
|
||||
Reference in new issue
Block a user