Skip to content
Onycx-ui
ESC

Parallax Image

Make a photo drift inside a fixed-ratio frame as the page scrolls, with an optional caption.

Dependencies
gsap
Size
118 lines
Controls
8 controls

Installation

CLI · shadcn registry

npx shadcn@latest add https://ui.onycx.dev/r/parallax-image.json

1 · Dependencies

npm install gsap

2 · Copy the source

components/onycx/parallax-image.tsx

Requires React 19 and Tailwind CSS v4. Copy the source from the parallax-image.tsx tab after tweaking: your values are baked in as the new defaults. Exported image examples use portable sample artwork. Replace it with your own media as needed.

Props

PropTypeDefaultDescription
src / altstring—Image source and description (empty alt for decorative images).
aspectstring"4 / 5"CSS aspect-ratio of the frame; the frame never resizes while scrolling.
amountnumber3yPercent drift each way, clamped to 0–20.
scalenumber1.08Constant overscan of the moving layer; never lower than 1 + 2 × amount / 100.
scrubnumber0.8ScrollTrigger scrub smoothing in seconds.
radiusnumber18Frame corner radius (px).
caption / captionIndexstring"A PALETTE YOU CAN FEEL." / "01"8px / .1em mocha caption row outside the moving layer. Empty caption hides it.
backgroundstring"#e5ded2"Frame colour behind a loading or failed image.
prioritybooleanfalseLoad eagerly for above-the-fold heroes.