Animated Checkbox
spell-ui/animated-checkboxFreeComponent
Animated checkbox with spring transitions and strike-through text effect.
Live preview
live · rendered by the registry
Rendered by spell-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://spell.sh/r/animated-checkbox.jsonSource
1"use client";23import { motion } from "motion/react";4import { useState } from "react";5import { cn } from "@/lib/utils";67interface AnimatedCheckboxProps {8 title?: string;9 defaultChecked?: boolean;10 className?: string;11 onCheckedChange?: (checked: boolean) => void;12}1314const springTransition = {15 type: "spring" as const,16 duration: 0.4,17 bounce: 0.2,18};1920export function AnimatedCheckbox({21 title = "Implement Checkbox",22 defaultChecked = false,23 className,24 onCheckedChange,25}: AnimatedCheckboxProps) {26 const [checked, setChecked] = useState(defaultChecked);2728 const handleClick = () => {29 const newChecked = !checked;30 setChecked(newChecked);31 onCheckedChange?.(newChecked);32 };3334 return (35 <div36 className={cn("flex items-center gap-3 cursor-pointer select-none", className)}37 onClick={handleClick}38 >39 <div40 className={cn(41 "size-4.5 rounded-[6px] flex items-center justify-center border-[1.5px] transition-colors duration-200",42 checked43 ? "bg-foreground border-transparent"44 : "bg-transparent border-muted-foreground/40 hover:border-muted-foreground/60"45 )}46 >47 <svg viewBox="0 0 20 20" className="size-full text-background">48 <motion.path49 d="M 0 4.5 L 3.182 8 L 10 0"50 fill="transparent"51 stroke="currentColor"52 strokeWidth={1.5}53 strokeLinecap="round"54 strokeLinejoin="round"55 transform="translate(5 6)"56 initial={{ pathLength: defaultChecked ? 1 : 0, opacity: defaultChecked ? 1 : 0 }}57 animate={{58 pathLength: checked ? 1 : 0,59 opacity: checked ? 1 : 060 }}61 transition={{62 pathLength: { ease: "easeOut", duration: 0.3 },63 opacity: { duration: 0 }64 }}65 />66 </svg>67 </div>68 <div className="relative">69 <span70 className={cn(71 "text-base font-medium transition-colors duration-200",72 checked ? "text-muted-foreground" : "text-foreground"73 )}74 >75 {title}76 </span>77 <motion.div78 className="absolute left-0 top-1/2 h-[1.5px] bg-muted-foreground -translate-y-1/2"79 initial={{ width: defaultChecked ? "100%" : 0, opacity: defaultChecked ? 1 : 0 }}80 animate={{81 width: checked ? "100%" : 0,82 opacity: checked ? 1 : 0,83 }}84// … truncated
What it pulls in
npm packages
Files it writes
More from spell-ui
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradientanimated-gradient | spell-ui | Components | Free | no deps | |
| Badgebadge | spell-ui | Components | Free | 2 deps | |
| Bars Spinnerbars-spinner | spell-ui | Components | Free | no deps | |
| Blur Revealblur-reveal | spell-ui | Components | Free | 1 dep | |
| Chartchart | spell-ui | Components | Free | no deps | |
| Color Selectorcolor-selector | spell-ui | Components | Free | no deps | |
| Copy Buttoncopy-button | spell-ui | Components | Free | 1 dep | |
| Exploding Inputexploding-input | spell-ui | Components | Free | no deps |
