26 lines
648 B
TypeScript
26 lines
648 B
TypeScript
'use client'
|
|
|
|
import * as React from 'react'
|
|
const NextThemesProvider = dynamic(
|
|
() => import('next-themes').then((e) => e.ThemeProvider),
|
|
{
|
|
ssr: false,
|
|
}
|
|
)
|
|
import { useTheme } from 'next-themes'
|
|
import { type ThemeProviderProps } from 'next-themes/dist/types'
|
|
import dynamic from 'next/dynamic'
|
|
|
|
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
|
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
|
}
|
|
|
|
export function useToggleTheme() {
|
|
const { theme, setTheme } = useTheme();
|
|
if (theme == "dark") {
|
|
return () => setTheme("light");
|
|
} else {
|
|
return () => setTheme("dark");
|
|
}
|
|
}
|