Theme Toggle

A button component that toggles between light and dark mode. Displays a sun icon in dark mode and a moon icon in light mode.

Usage

component.tsx
import ThemeToggle from "@/components/ui/theme-toggle"

export default function Page() {
    return (
        <ThemeToggle />
    )
}

Behavior

StateDisplay
Dark modeDisplays a Sun icon. Clicking switches to light mode.
Light modeDisplays a Moon icon. Clicking switches to dark mode.
Not mountedRenders null to avoid hydration mismatch.

The theme-toggle.tsx file already comes in the EasyToLaunch repo by default.

On this page