tween
ComponentsTemplatesShowcaseContact

Command Palette

Search for a command to run...

Getting Started
  • Introduction
  • Installation
  • StoryNew
Guides
  • Motion Principles
  • Scroll and Smooth Scroll
  • Performance and Accessibility
Scroll Animations
  • Sticky Cards Scroll
  • Rise Fan Cards Scroll
  • Rotate Stack Scroll
  • Doodle Lens ScrollNew
  • Slit Open Hero ScrollNew
  • Logo Mask Zoom ScrollNew
  • ASCII Dissolve ScrollNew
  • Lottie Flight ScrollNew
  • Inline Icon Text ScrollNew
  • Starfield ScrollNew
  • Name Swap ScrollNew
  • Spotlight Gallery HeroNew
  • Slit Rotate Hero ScrollNew
  • Stroke Cover ScrollNew
  • Stroke Rows ScrollNew
Text Animations
  • Text Skew Reveal
  • Block Text Reveal
Hover & Cursor
  • Image Trail Cursor
  • Cursor Depth Logo
  • Physics Tag Drop
  • Elastic Card ListNew
  • Magnetic Cards SpringNew
Sliders & Carousels
  • Wheel Fullscreen Carousel
  • Ripple Displacement Slider
  • Three.js Blend Slider
  • Stacked Deck Slider
  • Orbit Cylinder SliderNew
  • Fan Stack SliderNew
  • Exponential Strip SliderNew
  • Dual Column SliderNew
Galleries & Grids
  • Scroll Wave Gallery
Menus & Navigation
  • Shrink Page MenuNew
Preloaders & Intros
  • Floating Items RevealNew
  • Word Cycle RevealNew
  • Tile Grid LoaderNew
Page Transitions
  • Panel Assembly TransitionNew
3D & WebGL
  • Fractal Glass Hero
  • Fluid Cursor Canvas
  • Fluid Portrait Hero
  • Fluid Gradient Canvas
  • Inversion Lens HoverNew
UI Elements
  • Circular Widgets
  • Vinyl Cover
  • Image Explosion Footer
  • Accordion Image FramesNew

(Tween) — Motion registry

Animated components & full sites, one command away.

Product

  • Components
  • Templates
  • Installation
  • Guides
  • Blog
  • Contact

Categories

  • Scroll Animations
  • Text Animations
  • Hover & Cursor
  • Sliders & Carousels
  • Galleries & Grids
  • Menus & Navigation
  • Preloaders & Intros
  • Page Transitions
  • 3D & WebGL
  • UI Elements
TWEEN
ease: power2.inOut0.00s
© 2026 TweenBack to topBuilt by mohammad
  1. Docs/
  2. Components/
  3. Magnetic Cards Spring

Magnetic Cards Spring

PreviousNext

Four fanned photo cards on a spring-damper ticker — sweep the pointer past them and its velocity shoves the nearest card and tilts it, dragging neighbours along before everything springs back.

Open in
magnetic-cards-spring-demo
Sage-glazed pitcher holding red and white dahlias
Ribbed stoneware vase with irises and goldenrod
Blush-glazed vase with red and white roses
Turquoise two-handled urn filled with pink roses
components/ui/magnetic-cards-spring-demo.tsx
import { MagneticCardsSpring } from "@/registry/tween/magnetic-cards-spring"

export function MagneticCardsSpringDemo() {
  return <MagneticCardsSpring />
}

Installation

pnpm dlx shadcn@latest add https://tweenui.dev/r/magnetic-cards-spring.json

Usage

import { MagneticCardsSpring } from "@/components/ui/magnetic-cards-spring"
<MagneticCardsSpring
  cards={[
    { src: "/vessels/pitcher.jpg", alt: "Sage pitcher with dahlias" },
    { src: "/vessels/stoneware.jpg", alt: "Ribbed vase with irises" },
    { src: "/vessels/blush.jpg", alt: "Blush vase with roses" },
    { src: "/vessels/urn.jpg", alt: "Turquoise urn with roses" },
  ]}
/>

How it works

  • The cards rest in a fan: fixed x/y offsets and tilts around the center of the stage.
  • Pointer velocity is smoothed on every move. Each frame, a card within 500px of the pointer gets a push equal to that velocity times pushForce, weighted by (1 - distance / radius)³, so only fast sweeps close to a card move it.
  • Each card also feels its neighbours' pushes, falling off by 0.2 per step along the row, so a shove ripples sideways.
  • A spring-damper on the gsap.ticker pulls x, y and rotation back to rest: velocity gains (target - position) × stiffness and is multiplied by friction. Horizontal push also adds tilt.
  • The fan scales down below a 900px-wide container. With prefers-reduced-motion: reduce the cards stay in their resting fan.

Props

PropTypeDefaultDescription
cardsMagneticCard[]4 remoteEach card is { src, alt? }.
cardSizenumber250Card edge length in pixels at full size.
pushForcenumber10How hard pointer velocity pushes the cards.
stiffnessnumber0.05Spring pull back to rest.
frictionnumber0.85Velocity kept per frame.
backgroundstring"#17120f"Stage background.
classNamestring—Extra classes on the outer container.
Elastic Card ListWheel Fullscreen Carousel

On This Page

InstallationUsageHow it worksProps

Contribute

  • Report an issue
  • Request a feature
  • Edit this page