Cursor Attractor And Gravity Svg Demo
fancy/cursor-attractor-and-gravity-svg-demoFreeBlock
A block component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/cursor-attractor-and-gravity-svg-demo.jsonSource
1import { useState } from "react"23import Gravity, {4 MatterBody,5} from "@/components/fancy/physics/cursor-attractor-and-gravity"67export default function Preview() {8 const [debug, setDebug] = useState(false)910 return (11 <div className="w-dvw h-dvh flex flex-col relative justify-center items-center bg-white">12 <button13 onClick={() => setDebug(!debug)}14 className="absolute top-4 left-4 px-4 py-2 text-xs border border-border rounded-lg bg-background hover:bg-accent cursor-pointer z-10"15 >16 {debug ? "Disable Debug" : "Enable Debug"}17 </button>18 <p className="z-20 text-2xl sm:text-3xl md:text-3xl text-black">19 fancy components20 </p>21 <Gravity22 //attractorPoint={{ x: "33%", y: "50%" }}23 attractorStrength={0.0}24 cursorStrength={0.0005}25 cursorFieldRadius={200}26 className="w-full h-full"27 debug={debug}28 >29 {["#0015FF", "#E794DA"].map((color, i) => (30 <>31 <MatterBody32 key={`star1-${i}`}33 matterBodyOptions={{ friction: 0.5, restitution: 0.2 }}34 x={`${10 + Math.random() * 80}%`}35 y={`${10 + Math.random() * 80}%`}36 bodyType="svg"37 >38 <svg39 width="111"40 height="108"41 viewBox="0 0 111 108"42 fill="none"43 xmlns="http://www.w3.org/2000/svg"44 >45 <path46 d="M19.9185 107.176L33.6145 66.472L0.5905 44.328H41.0385L55.5025 0.679993L70.2225 44.328L110.415 44.328L77.3905 66.472L91.3425 107.176L55.5025 81.192L19.9185 107.176Z"47 fill={color}48 />49 </svg>50 </MatterBody>5152 <MatterBody53 key={`star2-${i}`}54 matterBodyOptions={{ friction: 0.5, restitution: 0.2 }}55 x={`${10 + Math.random() * 80}%`}56 y={`${10 + Math.random() * 80}%`}57 bodyType="svg"58 >59 <svg60 width="152"61 height="153"62 viewBox="0 0 152 153"63 fill="none"64 xmlns="http://www.w3.org/2000/svg"65 >66 <path67// … truncated
What it pulls in
Other registry items
Files it writes
More from fancy
All 158 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradient Demoanimated-gradient-demo | fancy | Blocks | Free | no deps | |
| Basic Number Ticker Demobasic-number-ticker-demo | fancy | Blocks | Free | no deps | |
| Box Carousel Autoplay Demobox-carousel-autoplay-demo | fancy | Blocks | Free | 1 dep | |
| Box Carousel Demobox-carousel-demo | fancy | Blocks | Free | 1 dep | |
| Box Carousel Video Demobox-carousel-video-demo | fancy | Blocks | Free | 1 dep | |
| Breathing Text Demobreathing-text-demo | fancy | Blocks | Free | no deps | |
| Circling Elements Democircling-elements-demo | fancy | Blocks | Free | no deps | |
| Circling Elements Easing Democircling-elements-easing-demo | fancy | Blocks | Free | no deps |
