Light Switch Theme Toggle
animated-theme-toggles/light-switchFreeBlock
Animated Theme Toggles publishes no description for this item.
Install it
npx shadcn@latest add https://toggles.dev/r/light-switch.jsonSource
1import { type ButtonHTMLAttributes, type CSSProperties, useId } from "react";23export interface LightSwitchProps extends Omit<4 ButtonHTMLAttributes<HTMLButtonElement>,5 "children"6> {7 duration?: number;8 [key: `data-${string}`]: string | number | boolean | null | undefined;9}1011export function LightSwitch({12 duration = 350,13 className,14 type = "button",15 title = "Toggle theme",16 "aria-label": ariaLabel = "Toggle theme",17 ...props18}: LightSwitchProps) {19 const toggleId = useId();2021 const clipPaddleId = `toggles.dev-light-switch-paddle-${toggleId}`;2223 return (24 <button25 type={type}26 title={title}27 aria-label={ariaLabel}28 className={className}29 {...props}30 >31 <svg32 width="1em"33 height="1em"34 viewBox="0 0 24 24"35 aria-hidden="true"36 style={37 {38 "--toggles-light-switch--duration": `${duration}ms`,39 } as CSSProperties40 }41 >42 <defs>43 <clipPath id={clipPaddleId}>44 <path45 d={"M7 3h10v9H7Z"}46 className="transition-[d,translate] duration-(--toggles-light-switch--duration) [transition-timing-function:cubic-bezier(0,0,0.15,1.25)] dark:[d:path('M7_12h10v9H7Z')] dark:not-supports-[d:path('M0_0')]:translate-y-[9px]"47 />48 </clipPath>49 </defs>50 <rect51 x={5}52 y={1}53 width={14}54 height={22}55 rx={2}56 stroke={"currentColor"}57 fill={"none"}58 strokeWidth={1.5}59 />60 <rect61 x={7}62 y={3}63 width={10}64 height={18}65 rx={1}66 stroke={"currentColor"}67 fill={"none"}68 strokeWidth={1}69 />70 <rect71 x={8}72 y={4}73 width={8}74 height={16}75 rx={0.5}76 fill={"currentColor"}77 clipPath={`url(#${clipPaddleId})`}78 />79 </svg>80 </button>81 );82}
Files it writes
More from Animated Theme Toggles
All 14 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Around Theme Togglearound | Animated Theme Toggles | Blocks | Free | no deps | |
| Classic Theme Toggleclassic | Animated Theme Toggles | Blocks | Free | no deps | |
| Dark Inner Theme Toggledark-inner | Animated Theme Toggles | Blocks | Free | no deps | |
| Dark Side Theme Toggledark-side | Animated Theme Toggles | Blocks | Free | no deps | |
| Eclipse Theme Toggleeclipse | Animated Theme Toggles | Blocks | Free | no deps | |
| Expand Theme Toggleexpand | Animated Theme Toggles | Blocks | Free | no deps | |
| Half Sun Theme Togglehalf-sun | Animated Theme Toggles | Blocks | Free | no deps | |
| Horizon Theme Togglehorizon | Animated Theme Toggles | Blocks | Free | no deps |
