Morphiq

Components / Animations / Scroll Expand

Scroll Expand

A framed panel that opens to full bleed as you scroll past it. JS writes two custom properties and CSS does the rest, so children can join the animation without any wiring.

Usage

import ScrollExpand from '@/components/scroll-expand'

<ScrollExpand
  width={62}
  height={48}
  smoothing={0.12}
/>

Installation

npx shadcn@latest add https://morphiq.prathampatel.design/r/scroll-expand.json

Model

p = clamp((scroll − start) / (travel·vh), 0, 1)

p is written to two CSS variables anything inside can read

Props

PropertyTypeDefaultDescription
mediaReactNode—Whatever sits inside the frame — an image, a video, a canvas.
widthnumber42Starting frame width, as a percentage of the viewport.
heightnumber58Starting frame height, as a percentage of the viewport.
radiusnumber24Corner radius at rest, in px.
endRadiusnumber0Corner radius once fully open, in px.
zoomnumber1.35Scale the media starts pushed in at.
scrimnumber0.45Peak darkening over the media, 0..1.
travelnumber1.2Scroll budget, as a multiple of the pinned panel's height.
holdnumber0.35Fraction of that budget spent held fully open.
smoothingnumber0.09Per-frame approach rate for the eased value.
easeScrollEase'inOut'—
onProgress(progress: number) => void—Called with raw progress, 0..1, on every frame it changes.
childrenReactNode——