BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/rivelle/magnetic-button

Magnetic Button

rivelle/magnetic-button
FreeComponent

A tactile action that leans toward the pointer and snaps back.

Install it

npx shadcn@latest add https://rivelle.dev/r/magnetic-button.json

Source

registry/nova/effects/magnetic-button.tsxrivelle.dev/r/magnetic-button.json
1"use client";
2
3import * as React from "react";
4
5import { cn } from "@/lib/utils";
6
7type MagneticButtonProps = React.ComponentProps<"button"> & {
8 strength?: number;
9};
10
11function MagneticButton({
12 children,
13 className,
14 onPointerLeave,
15 onPointerMove,
16 strength = 18,
17 style,
18 type = "button",
19 ...props
20}: MagneticButtonProps) {
21 const frame = React.useRef<number | null>(null);
22
23 const move = (
24 element: HTMLButtonElement,
25 x: number,
26 y: number,
27 glowX: number,
28 glowY: number,
29 ) => {
30 if (frame.current !== null) cancelAnimationFrame(frame.current);
31 frame.current = requestAnimationFrame(() => {
32 element.style.setProperty("--magnetic-x", `${x}px`);
33 element.style.setProperty("--magnetic-y", `${y}px`);
34 element.style.setProperty("--magnetic-glow-x", `${glowX}%`);
35 element.style.setProperty("--magnetic-glow-y", `${glowY}%`);
36 });
37 };
38
39 React.useEffect(
40 () => () => {
41 if (frame.current !== null) cancelAnimationFrame(frame.current);
42 },
43 [],
44 );
45
46 return (
47 <button
48 className={cn(
49 "group relative inline-flex min-h-12 items-center justify-center gap-2 overflow-hidden rounded-full bg-foreground px-6 text-sm font-semibold text-background shadow-[0_18px_50px_-24px_var(--foreground)] outline-none transition-[transform,box-shadow] duration-200 ease-out hover:shadow-[0_24px_65px_-28px_var(--foreground)] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:scale-[.98] disabled:pointer-events-none disabled:opacity-50 motion-reduce:transform-none motion-reduce:transition-none",
50 className,
51 )}
52 data-slot="magnetic-button"
53 onPointerLeave={(event) => {
54 move(event.currentTarget, 0, 0, 50, 50);
55 onPointerLeave?.(event);
56 }}
57 onPointerMove={(event) => {
58 if (!window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
59 const bounds = event.currentTarget.getBoundingClientRect();
60 const relativeX = (event.clientX - bounds.left) / bounds.width;
61 const relativeY = (event.clientY - bounds.top) / bounds.height;
62 const x = (relativeX - 0.5) * strength * 0.72;
63 const y = (relativeY - 0.5) * strength * 0.72;
64 move(event.currentTarget, x, y, relativeX * 100, relativeY * 100);
65 }
66 onPointerMove?.(event);
67 }}
68 style={
69 {
70 "--magnetic-glow-x": "50%",
71// … truncated

What it pulls in

Other registry items

  • @rivelle/utils

Files it writes

  • registry/nova/effects/magnetic-button.tsx

Facts

Registry
rivelle
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
In the index
at or before 2026-08-12
Last confirmed
today

Go to the source

Docs on rivelle rivelle.dev w3cproject/rivelle-ui on GitHub Raw registry item This item as JSON

More from rivelle

All 83 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionrivelleComponentsFree2 deps
AlertalertrivelleComponentsFree1 dep
Alert Dialogalert-dialogrivelleComponentsFree1 dep
Aspect Ratioaspect-ratiorivelleComponentsFree1 dep
AvataravatarrivelleComponentsFree1 dep
BadgebadgerivelleComponentsFree2 deps
BreadcrumbbreadcrumbrivelleComponentsFree2 deps
ButtonbuttonrivelleComponentsFree2 deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

KitGrade

SaaS starter kits, scored from measured facts

kitgrade.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and KitGrade

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex