Gravity Well

ProShowcase & Media3DWebGLpowered by @vectorvesper/motion
Gravity Well

Included with membership

Members install Gravity Well with one command and get the full source, the usage code and the Framer remix, licensed for client work. One membership covers the whole library and the CLI.

When to use it

A showcase strip for work, products or logos that should feel physical rather than flat: a portfolio header, a launch page, a section between two blocks of copy. It wants width, because the cards approach the ring from the left, and it fills the screen's height unless you give it one.

  • Give every item a title. It is what screen readers hear, and it is drawn as text when an item has no image or HTML.
  • Set a height with style or className. It defaults to the full height of the screen.
  • Use transparent PNGs or SVGs with fit="contain" for logos and products. They keep their own outline instead of sitting on a card.
  • Put headings and links in children. Links and buttons there stay clickable, and the rest of the overlay lets drags through to the belt.
  • Pass a poster. It shows before the scene builds, and instead of it for visitors who prefer reduced motion.
  • Keep the items array stable between renders, for example with a constant or useMemo. HTML items are drawn once each and cached by their markup.

Avoid:

  • Do not pass HTML from your visitors. Scripts, styles, frames and event handlers are stripped, but nothing else is checked, so only use markup you wrote.
  • Do not rely on a font that only an HTML item uses. Cards are drawn once, when the page's fonts are ready, so use fonts the page already loads.
  • Do not use it as the only way to reach the items. The belt keeps moving, and only cards on top of the glass and clear of the ring can be clicked. Link to the same pages somewhere still.
  • Do not load images from another site without CORS. Images are drawn by the GPU, which needs crossOrigin to match what the server allows.
  • Do not move ringX far left. Cards approach the ring from the left, so the space left of it is where the belt is seen.

Props

A ticker of images or HTML cards that runs along the top of a sheet of hammered glass and falls into a polished metal ring. As each card nears the opening it turns, crumples and drops through, then comes back out under the glass on a lower row, seen through the frost, before climbing back on at the left. Visitors can drag, swipe, scroll or use the arrow keys to move the belt, and cards on top of the glass can be clicked.

<GravityWell />

The belt, the glass and the ring. Fills its container's width and paints its own background. Takes any prop a div takes, as well as these.

PropTypeDefaultDescription
itemsArray<string | GravityWellItem>[]Image URLs, or items with an image, HTML or a title. They repeat along the belt.
fit"contain" | "cover""contain""contain" keeps each item's own shape, transparent edges included. "cover" crops it to fill the card.
speednumber0.35Belt speed in cards per second. Negative runs it backwards.
pausedbooleanfalseStops the belt. Dragging still moves it.
pauseOnHoverbooleanfalseSlows the belt to a stop while the pointer is over it.
draggablebooleantrueDrag or swipe sideways to scrub the belt, and let go to fling it. Vertical swipes still scroll the page.
dragSensitivitynumber1How far a drag, fling or wheel turn moves the belt.
wheelScrubbooleantrueThe mouse wheel and trackpad move the belt as well as the page.
ringXnumber0.72Centre of the ring across the element, 0 to 1. On narrow portrait screens it eases towards the middle.
ringYnumber0.5Centre of the ring down the element, 0 to 1.
ringSizenumber0.08Diameter of the opening, as a fraction of the element's height.
ringThicknessnumber0.36Thickness of the ring's tube, as a fraction of the opening's radius.
ringColorstring"#e8dfcb"Tint of the metal. Near-white reads as steel, warm tones as champagne.
ringRoughnessnumber0.060 is a mirror, 1 is brushed.
cardSizenumber0.24Card height, as a fraction of the element's height.
cardAspectnumber1.5Card width over height.
gapnumber0.18Space between cards, as a fraction of the card width.
rowOffsetnumber1.05How far below the top row the row under the glass runs, in card heights.
swirlnumber0.95How far a card turns as it falls in, in radians.
foldsnumber9How many folds a card crumples into inside the ring. 0 for none.
pullReachnumber1How far from the ring the pull starts, as a multiplier.
backgroundstring"#f2f0eb"The ground under the glass, and the colour shown before the scene builds.
frostnumber0.05How frosted the glass is, 0 to 1.
milknumber0How milky the glass is, 0 to 1.
glassGrainnumber1.2Strength of the hammered, pebbled texture. 0 for smooth glass.
glassRefractnumber1.2How much the pebbles bend what is under them.
shadowOpacitynumber0.2Strength of the cards' shadows on the glass, 0 to 1.
leftBlurnumber0.22Width of the blurred entry at the left edge, as a fraction of the element's width. 0 turns it off.
parallaxnumber1How far the scene leans with the pointer. 0 turns it off.
posterstring—Image shown before the scene builds and under reduced motion. Without one, a still drawing of the belt and ring is shown.
crossOrigin"anonymous" | "use-credentials""anonymous"How images from another origin are requested.
labelstring"Image ticker"Accessible name for the ticker.
onCardClick(index: number, item: GravityWellItem) => void—Fired when a card on top of the glass is clicked or tapped, with its index in items. Runs before the item's href is followed.
onCardHover(index: number | null, item: GravityWellItem | null) => void—Fired when the pointer moves onto a card, and with null when it leaves.
childrenReact.ReactNode—Laid over the scene. Links and buttons inside stay clickable; the rest lets the pointer through to the belt.

<GravityWellItem />

type

One item on the belt.

PropTypeDefaultDescription
urlstring—Image URL: PNG, WebP, JPG or SVG. Transparent PNGs keep their shape.
htmlstring—Trusted markup drawn into the card instead of an image. Supports backgrounds, gradients, borders, radii, box shadows, opacity, text and inline SVG paths.
titlestring—Read by screen readers, and drawn as text when there is no image or HTML.
subtitlestring—Extra text carried with the item, for your own handlers.
aspectnumber—Width over height, used until the image has loaded.
hrefstring—Followed when the card is clicked.
target"_self" | "_blank""_self"Where href opens.
altstringtitleAccessible description.
For visitors who prefer reduced motion, the scene never starts. They see the poster if you pass one, or a still drawing of the cards, glass and ring. The same happens on devices too weak to draw it smoothly.
It runs on the shared frame loop and waits to build until it is near the viewport and the page has frame headroom. It stops drawing when scrolled off screen. When frames get tight it drops to a lower pixel ratio and a cheaper glass pass.
If the browser takes the graphics context away, the scene rebuilds itself. Keyboard users can focus the ticker and move the belt a card at a time with the left and right arrow keys, and screen readers get the items as a plain list.
Client component. It opens a 3D drawing context on mount, so import it dynamically with ssr: false if your route renders on the server.
Needs @vectorvesper/motion 4.2.0 or later, the first version with @vectorvesper/motion/three. If your project has an older version, update it before adding this component.
Back to all components