Media that starts as an inset, rounded card and opens to fill the view as the page scrolls, then softens as it leaves.
pnpm dlx shadcn@latest add @latheui/zoom-framePart of Lathe Pro. Set up your project once with your license key: npx latheui init --key <key>. See Lathe Pro.
Zoom Frame is part of Lathe Pro
The preview is live and free to try. The source, the install and every assembly come with Pro: $79 once, with lifetime updates.
Depends on
Also accepts native section attributes. The section is as tall as the scroll it takes; the frame sticks to the top while it plays.
| Prop | Type | Default | Description |
|---|---|---|---|
| children* (required) | ReactNode | — | The media: an img, a video, or anything that covers its box. |
| overlay | ReactNode | — | Laid over the media, for a headline. It fades as the frame opens. |
| startWidth | number | 0.56 | Width of the closed frame, as a fraction of the view. |
| startHeight | number | 0.6 | Height of the closed frame, as a fraction of the view. |
| radius | number | 28 | Corner radius of the closed frame, in px. |
| length | number | 2.4 | How far the section scrolls, in view heights. |
| openAt | number | 0.6 | Fraction of the scroll at which the frame is fully open. |
| exit | "none" | "blur" | "fade" | "blur" | What happens over the rest of the scroll. |
| zoom | number | 1.18 | The media starts this much larger and settles as the frame opens. |
| viewportHeight | string | "100dvh" | Height of the view the frame fills. Use the scrolling container's height when it is not the window. |
| container | RefObject<HTMLElement> | — | The element that scrolls, when it is not the window. Give it position: relative so the frame's place in it is measured from its top. |
| curve | Curve | power 2, in and out | How the frame opens against the scroll. Any curve from the Animation Lab. |
<ZoomFrame openAt={0.4} length={2}>
<img src="/hero.jpg" alt="The studio" />
</ZoomFrame>