-
Notifications
You must be signed in to change notification settings - Fork 17
/
theme-toggle.tsx
39 lines (34 loc) · 1.19 KB
/
theme-toggle.tsx
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
34
35
36
37
38
39
"use client"
import * as React from "react"
import { MoonStar, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
export function ThemeToggle() {
const { setTheme } = useTheme()
return (
<div className="flex justify-center md:justify-start">
<ToggleGroup
type="single"
className="w-fit rounded-full border p-1 text-muted-foreground"
defaultValue={"dark"}
>
<ToggleGroupItem
className="rounded-full"
onClick={() => setTheme("light")}
value="light"
aria-label="Toggle light"
>
<Sun className="size-3" />
</ToggleGroupItem>
<ToggleGroupItem
className="rounded-full"
onClick={() => setTheme("dark")}
value="dark"
aria-label="Toggle dark"
>
<MoonStar className="size-3" />
</ToggleGroupItem>
</ToggleGroup>
</div>
)
}