commerce/site/lib/hooks/useToggleTheme.ts
2022-11-30 08:12:26 +02:00

12 lines
338 B
TypeScript

import { useTheme } from 'next-themes'
import { useEffect, useState } from 'react'
export const useToggleTheme = () => {
const { theme, themes, setTheme } = useTheme()
const [themeValue, setThemeValue] = useState<string>('system')
useEffect(() => setThemeValue(theme), [theme])
return { theme: themeValue, setTheme, themes }
}