Controls & Inputs

Theme Toggle

라이트/다크 테마를 전환하는 간결한 스위치형 토글입니다.

Preview

theme control

Theme Toggle

switch with different transitions

Installation

bash
Copied
1pnpm dlx shadcn@latest add https://ryong-blog.vercel.app/r/toggle-theme.json

Code

typescript
Copied
1import { ToggleTheme } from "@/components/toggle-theme"23export default function Example() {4  return <ToggleTheme />5}

Props

className

Type
string
Default
-
Description
Additional classes merged onto the component.

duration

Type
number
Default
400
Description
View Transition animation duration in milliseconds.

animationType

Type
"none" | "circle-spread" | "round-morph" | "swipe-left" | "swipe-up" | "diag-down-right" | "fade-in-out" | "shrink-grow" | "flip-x-in" | "split-vertical" | "swipe-right" | "swipe-down" | "wave-ripple"
Default
"circle-spread"
Description
Lightswind View Transition animation style.

variant

Type
"default" | "glass"
Default
"default"
Description
Visual surface style.

defaultChecked

Type
boolean
Default
false
Description
Initial checked state.

onChange

Type
(checked: boolean) => void
Default
-
Description
Change handler.

Reference

Lightswind Toggle Theme