-
-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathindex.js
33 lines (28 loc) · 832 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { useTheme } from 'next-themes'
import Link from 'next/link'
import { useEffect, useState } from 'react'
const Index = () => {
const { theme, setTheme } = useTheme()
const [mounted, setMounted] = useState(false)
useEffect(() => setMounted(true), [])
return (
<div>
<h1>next-themes Example</h1>
<select value={theme} onChange={e => setTheme(e.target.value)} data-test-id="theme-selector">
<option value="system">System</option>
{mounted && (
<>
<option value="dark">Dark</option>
<option value="light">Light</option>
</>
)}
</select>
<br />
<br />
<div>
<Link href="/dark">Forced Dark Page</Link> • <Link href="/light">Forced Light Page</Link>
</div>
</div>
)
}
export default Index