Skip to content

Commit

Permalink
fix(react): store selected theme locally
Browse files Browse the repository at this point in the history
  • Loading branch information
devshred committed Jun 30, 2024
1 parent 45399ac commit 869e8dc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/routes/-components/ThemeSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useEffect, useState } from 'react'
import { useEffect } from 'react'
import { useLocalStorage } from '@uidotdev/usehooks'

export type Theme = 'light' | 'dark'

const ThemeSwitcher = () => {
const [theme, setTheme] = useState<Theme>('dark')
const [theme, setTheme] = useLocalStorage<Theme>('gps-tools_theme', 'dark')

useEffect(() => {
document.querySelector('html')?.setAttribute('data-theme', theme)
Expand Down

0 comments on commit 869e8dc

Please sign in to comment.