Dark mode
The system preference, a switcher and the dark variant.
Overview
Dark and moonlight are the two dark themes. The provider follows the operating system until someone picks a theme, and setTheme from next-themes switches it anywhere in your app.
The dark: variant applies under both dark themes and answers to the nearest theme, so a light panel nested inside a dark page reads as light. An app with one theme pins it with forcedTheme.
TSX
"use client"
import { useTheme } from "next-themes"
import { Button } from "@/components/ui/button"
export function MoonlightButton() {
const { setTheme } = useTheme()
return <Button onClick={() => setTheme("moonlight")}>Moonlight</Button>
}New to Koala UI?
The Quickstart sets Koala UI up in a React app and renders your first component in about five minutes.