Spotlight Logo
ncdai/spotlight-logoFreeComponent
SVG logo with a cursor-tracking gradient highlight and tactile press.
Install it
npx shadcn@latest add https://chanhdai.com/r/spotlight-logo.jsonSource
1"use client"23import { useEffect, useId, useRef } from "react"4import type { Transition } from "motion/react"5import {6 motion,7 useInView,8 useMotionValue,9 useReducedMotion,10 useSpring,11 useTransform,12} from "motion/react"1314import { metalClickSound } from "@/lib/soundcn/metal-click"15import { useSound } from "@/hooks/soundcn/use-sound"1617const transition: Transition = {18 type: "spring",19 mass: 0.5,20 damping: 18,21 stiffness: 200,22}2324/**25 * An SVG mark whose outline is traced by a gradient highlight that follows the26 * cursor, paired with a springy press effect and a tactile click sound.27 *28 * Swap the SVG paths below for your own artwork. The interaction is driven by:29 * - a `radialGradient` whose center springs toward the pointer (the spotlight),30 * reused as a second stroke layered over the base outline.31 * - `whileTap="pressed"` morphing the path `d` values between two states.32 *33 * The demo mark was designed by ncdai on Figma with the34 * [Fast Isometric Plugin](https://www.figma.com/community/plugin/1249759048471403961).35 * Inspired by tailwindcss.com.36 */37export function SpotlightLogo() {38 const id = useId()39 const ids = {40 facePattern: `spotlight-logo-face-pattern-${id}`,41 faceFill: `spotlight-logo-face-fill-${id}`,42 stroke: `spotlight-logo-stroke-${id}`,43 radialGradient: `spotlight-logo-radial-gradient-${id}`,44 }4546 const ref = useRef<SVGSVGElement>(null)4748 const [play] = useSound(metalClickSound)4950 const shouldReduceMotion = useReducedMotion()51 const isInView = useInView(ref, { margin: "80px" })5253 const mouseX = useMotionValue(0.5)54 const mouseY = useMotionValue(0.5)5556 const cx = useSpring(useTransform(mouseX, [0, 1], [0, 556]), {57 stiffness: 300,58 damping: 30,59 mass: 0.1,60 })6162 const cy = useSpring(useTransform(mouseY, [0, 1], [0, 354]), {63 stiffness: 300,64 damping: 30,65 mass: 0.1,66 })6768 useEffect(() => {69 if (shouldReduceMotion || !isInView) {70 return71 }7273 if (window.matchMedia("(hover: none)").matches) {74 return75 }7677 const handleMouseMove = (e: MouseEvent) => {78 mouseX.set(e.clientX / window.innerWidth)79 mouseY.set(e.clientY / window.innerHeight)80 }8182 window.addEventListener("mousemove", handleMouseMove)8384 return () => {85 window.removeEventListener("mousemove", handleMouseMove)86 }87 }, [shouldReduceMotion, isInView, mouseX, mouseY])8889 return (90 <motion.svg91 ref={ref}92// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from ncdai
All 17 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Apple Hello Effectapple-hello-effect | ncdai | Components | Unverified | 1 dep | |
| Apple Hello Effect - Hindiapple-hello-effect-hindi | ncdai | Components | Unverified | 1 dep | |
| Apple Hello Effect - Spanishapple-hello-effect-spanish | ncdai | Components | Unverified | 1 dep | |
| Apple Hello Effect - Vietnameseapple-hello-effect-vietnamese | ncdai | Components | Unverified | 1 dep | |
| Brand Assets Menubrand-assets-menu | ncdai | Components | Unverified | 1 dep | |
| chevrons-up-down-iconchevrons-up-down-icon | ncdai | Components | Unverified | 1 dep | |
| Code Block Commandcode-block-command | ncdai | Components | Unverified | 3 deps · 2 files | |
| Consent Managerconsent-manager | ncdai | Components | Unverified | 1 dep |
