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.
| Prop | Type | Default | Description |
|---|---|---|---|
items | Array<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. |
speed | number | 0.35 | Belt speed in cards per second. Negative runs it backwards. |
paused | boolean | false | Stops the belt. Dragging still moves it. |
pauseOnHover | boolean | false | Slows the belt to a stop while the pointer is over it. |
draggable | boolean | true | Drag or swipe sideways to scrub the belt, and let go to fling it. Vertical swipes still scroll the page. |
dragSensitivity | number | 1 | How far a drag, fling or wheel turn moves the belt. |
wheelScrub | boolean | true | The mouse wheel and trackpad move the belt as well as the page. |
ringX | number | 0.72 | Centre of the ring across the element, 0 to 1. On narrow portrait screens it eases towards the middle. |
ringY | number | 0.5 | Centre of the ring down the element, 0 to 1. |
ringSize | number | 0.08 | Diameter of the opening, as a fraction of the element's height. |
ringThickness | number | 0.36 | Thickness of the ring's tube, as a fraction of the opening's radius. |
ringColor | string | "#e8dfcb" | Tint of the metal. Near-white reads as steel, warm tones as champagne. |
ringRoughness | number | 0.06 | 0 is a mirror, 1 is brushed. |
cardSize | number | 0.24 | Card height, as a fraction of the element's height. |
cardAspect | number | 1.5 | Card width over height. |
gap | number | 0.18 | Space between cards, as a fraction of the card width. |
rowOffset | number | 1.05 | How far below the top row the row under the glass runs, in card heights. |
swirl | number | 0.95 | How far a card turns as it falls in, in radians. |
folds | number | 9 | How many folds a card crumples into inside the ring. 0 for none. |
pullReach | number | 1 | How far from the ring the pull starts, as a multiplier. |
background | string | "#f2f0eb" | The ground under the glass, and the colour shown before the scene builds. |
frost | number | 0.05 | How frosted the glass is, 0 to 1. |
milk | number | 0 | How milky the glass is, 0 to 1. |
glassGrain | number | 1.2 | Strength of the hammered, pebbled texture. 0 for smooth glass. |
glassRefract | number | 1.2 | How much the pebbles bend what is under them. |
shadowOpacity | number | 0.2 | Strength of the cards' shadows on the glass, 0 to 1. |
leftBlur | number | 0.22 | Width of the blurred entry at the left edge, as a fraction of the element's width. 0 turns it off. |
parallax | number | 1 | How far the scene leans with the pointer. 0 turns it off. |
poster | string | — | 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. |
label | string | "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. |
children | React.ReactNode | — | Laid over the scene. Links and buttons inside stay clickable; the rest lets the pointer through to the belt. |
<GravityWellItem />
typeOne item on the belt.
| Prop | Type | Default | Description |
|---|---|---|---|
url | string | — | Image URL: PNG, WebP, JPG or SVG. Transparent PNGs keep their shape. |
html | string | — | Trusted markup drawn into the card instead of an image. Supports backgrounds, gradients, borders, radii, box shadows, opacity, text and inline SVG paths. |
title | string | — | Read by screen readers, and drawn as text when there is no image or HTML. |
subtitle | string | — | Extra text carried with the item, for your own handlers. |
aspect | number | — | Width over height, used until the image has loaded. |
href | string | — | Followed when the card is clicked. |
target | "_self" | "_blank" | "_self" | Where href opens. |
alt | string | title | Accessible description. |
ssr: false if your route renders on the server.@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.