Analog Clock Screensaver
refinery/analog-clock-screensaverFreeComponent
SVG analog clock screensaver with smooth hands motion.
Live preview
live · rendered by the registry
Rendered by refinery on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://refinery.abhii.me/r/analog-clock-screensaver.jsonSource
1"use client";23import { useRef } from "react";4import { useAnimationFrame } from "motion/react";5import { cn } from "@/lib/utils";67interface AnalogClockScreensaverProps {8 title?: string;9 className?: string;10 accentColor?: string;11 backgroundClassName?: string;12}1314export default function AnalogClockScreensaver({15 title = "Refinery",16 className = "",17 accentColor = "#d13b28",18 backgroundClassName = "bg-neutral-900",19}: AnalogClockScreensaverProps) {20 const secondHandRef = useRef<SVGLineElement | null>(null);21 const minuteHandRef = useRef<SVGLineElement | null>(null);22 const hourHandRef = useRef<SVGLineElement | null>(null);2324 useAnimationFrame(() => {25 const now = new Date();26 const seconds = now.getSeconds() + now.getMilliseconds() / 1000;27 const minutes = now.getMinutes() + seconds / 60;28 const hours = (now.getHours() % 12) + minutes / 60;2930 secondHandRef.current?.setAttribute(31 "transform",32 `rotate(${seconds * 6} 50 50)`33 );34 minuteHandRef.current?.setAttribute(35 "transform",36 `rotate(${minutes * 6} 50 50)`37 );38 hourHandRef.current?.setAttribute(39 "transform",40 `rotate(${hours * 30} 50 50)`41 );42 });4344 return (45 <div46 className={cn(47 "flex h-screen w-full flex-col items-center justify-center gap-2 text-neutral-100",48 backgroundClassName,49 className50 )}51 >52 <svg53 viewBox="0 0 100 100"54 className="size-[min(80vw,20rem)] overflow-visible rounded-full"55 role="img"56 aria-label="Analog clock"57 >58 <circle59 cx="50"60 cy="50"61 r="48"62 fill="none"63 stroke="currentColor"64 strokeOpacity="0.14"65 strokeWidth="1.5"66 />67 <line68 ref={hourHandRef}69 x1="50"70 y1="50"71 x2="50"72 y2="28"73 stroke="currentColor"74 strokeLinecap="round"75 strokeWidth="3"76 />77 <line78 ref={minuteHandRef}79 x1="50"80 y1="50"81 x2="50"82 y2="20"83 stroke="currentColor"84 strokeLinecap="round"85 strokeWidth="2.2"86 />87 <line88 ref={secondHandRef}89 x1="50"90 y1="56"91 x2="50"92 y2="12"93 stroke={accentColor}94 strokeLinecap="round"95 strokeWidth="1.5"96 />97 <circle98 cx="50"99 cy="50"100 r="2.6"101// … truncated
What it pulls in
npm packages
Files it writes
More from refinery
All 16 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Avatar Circleavatar-circle | refinery | Components | Free | 1 dep | |
| DVD Screensaverdvd-screensaver | refinery | Components | Free | 1 dep | |
| Floating Cardfloating-card | refinery | Components | Free | 1 dep | |
| Floating Navfloating-nav | refinery | Components | Free | 1 dep | |
| Glowy Buttonglowy-button | refinery | Components | Free | 1 dep | |
| Move To Topmove-to-top-button | refinery | Components | Free | 1 dep | |
| Notification Badgenotification-badge | refinery | Components | Free | 1 dep | |
| Sleeping Cat Screensaversleeping-cat-screensaver | refinery | Components | Free | 2 deps |
