Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/docs/content/docs/customization/dark-mode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Add the theme switcher to your app.
"use client";

import {useTheme} from "next-themes";
import { useEffect, useState } from "react";
import {useEffect, useState} from "react";

export function ThemeSwitcher() {
const [mounted, setMounted] = useState(false)
Expand All @@ -100,7 +100,7 @@ export function ThemeSwitcher() {
setMounted(true)
}, [])

if(!mounted) return null
if (!mounted) return null

return (
<div>
Expand Down Expand Up @@ -165,10 +165,18 @@ Add the theme switcher to your app.
```jsx
// components/ThemeSwitcher.tsx
import {useTheme} from "next-themes";
import {useEffect, useState} from "react";

export const ThemeSwitcher = () => {
const [mounted, setMounted] = useState(false)
const { theme, setTheme } = useTheme()

useEffect(() => {
setMounted(true)
}, [])

if (!mounted) return null

return (
<div>
The current theme is: {theme}
Expand Down