Fancy Theme Toggle
atlas-ui/fancy-theme-toggleFreeComponent
Theme Toggle from the classic Designer vs Developer meme.
Live preview
live · rendered by the registry
Rendered by atlas-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://atlasui.dev/r/fancy-theme-toggle.jsonSource
1"use client";23import { useCallback } from "react";45import { useTheme } from "next-themes";67import { CloudIcon, SparkleIcon } from "lucide-react";8import { motion } from "motion/react";910export const ThemeToggle = () => {11 const { setTheme, resolvedTheme } = useTheme();1213 const toggleTheme = useCallback(() => {14 setTheme(resolvedTheme === "dark" ? "light" : "dark");15 }, [resolvedTheme, setTheme]);1617 return (18 <button19 onClick={toggleTheme}20 role="switch"21 className="relative flex w-20 justify-start overflow-hidden rounded-full bg-linear-to-b from-blue-500 to-blue-300 p-1.5 shadow-[inset_0_2px_4px_rgba(0,0,0,0.3),inset_0_-2px_3px_rgba(0,0,0,0.1)] dark:justify-end dark:from-neutral-900 dark:to-neutral-800"22 >23 <Thumb />2425 {resolvedTheme === "dark" ? <Stars /> : <Clouds />}26 </button>27 );28};2930const Thumb = () => {31 return (32 <motion.div33 layout34 transition={{35 type: "spring",36 stiffness: 420,37 damping: 32,38 mass: 0.6,39 }}40 className="relative size-7 rounded-full bg-linear-to-br from-yellow-300 to-yellow-400 shadow-[inset_1px_1px_2px_0px_rgba(255,255,255),0px_3px_9px_4px_rgba(0,0,0,0.141)] dark:from-gray-200 dark:to-gray-300 dark:after:absolute dark:after:bottom-1.5 dark:after:left-1 dark:after:size-3 dark:after:rounded-full dark:after:bg-gray-400 dark:after:shadow-[6px_-10px_0_-3.5px_var(--color-gray-400),10px_4px_0_-3px_var(--color-gray-400)] dark:after:content-['']"41 />42 );43};4445const Stars = () => {46 return (47 <motion.div48 initial={{ y: "-100%" }}49 animate={{ y: 0 }}50 transition={{51 duration: 0.2,52 ease: "easeOut",53 }}54 className="absolute inset-0"55 >56 <SparkleIcon className="absolute top-2 left-2 size-2 fill-gray-400 stroke-0" />57 <SparkleIcon className="absolute top-4 left-5 size-2.5 fill-gray-400 stroke-0" />58 <SparkleIcon className="absolute top-2 left-10 size-1 fill-gray-400 stroke-0" />59 <SparkleIcon className="absolute top-1 left-7 size-1 fill-gray-400 stroke-0" />60 <SparkleIcon className="absolute bottom-2 left-2 size-1 fill-gray-400 stroke-0" />61 <SparkleIcon className="absolute bottom-2 left-8 size-1 fill-gray-400 stroke-0" />62 <SparkleIcon className="absolute bottom-1 left-5 size-1.5 fill-gray-400 stroke-0" />63 </motion.div>64 );65};6667const Clouds = () => {68 return (69 <motion.div70 initial={{ y: "100%" }}71 animate={{ y: 0 }}72 transition={{73// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from atlas-ui
All 99 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Mobile Navbaranimated-mobile-navbar | atlas-ui | Components | Free | 2 deps | |
| Blend Mouse Trailerblend-mouse-trailer | atlas-ui | Components | Free | 1 dep | |
| Blob Mouse Trailerblob-mouse-trailer | atlas-ui | Components | Free | 1 dep | |
| Box Revealbox-reveal | atlas-ui | Components | Free | 1 dep | |
| Cascade Textcascade-text | atlas-ui | Components | Free | 1 dep | |
| Dot And Circle Mouse Trailerdot-and-circle-mouse-trailer | atlas-ui | Components | Free | 1 dep | |
| Hacker Texthacker-text | atlas-ui | Components | Free | no deps | |
| Letter Swapletter-swap | atlas-ui | Components | Free | 1 dep |
