Preview

Button
Switch
LightDark

Installation

<> import.ts
import { ThemeToggle } from "@/components/ui/theme-toggle"

Code

<> component.tsx
import { ThemeToggle } from "@/components/ui/theme-toggle"

<ThemeToggle />

API Reference

ThemeToggle

Toggle between light and dark themes using a button or switch.

<> import.ts
import { ThemeToggle } from "@/components/ui/theme-toggle"

Props

PropTypeDefaultDescription
variant
"button" | "switch""button"Render as icon button or as a labeled switch
size
"sm" | "md" | "lg""md"Control size (switch/button)
className
string""Additional classes
lightIcon
React.ReactNodeCustom icon for light theme
darkIcon
React.ReactNodeCustom icon for dark theme
leftLabel
stringLeft label for switch variant
rightLabel
stringRight label for switch variant

Examples

Example 1
<> example.tsx
// Icon button
<ThemeToggle />
Example 2
<> example.tsx
// Switch with labels
<ThemeToggle variant="switch" leftLabel="Light" rightLabel="Dark" />