GooseUI

Components

Hover Scroll Screenshot

New

A full-page screenshot in a frame with fixed proportions. On hover it scrolls down, and if the pointer leaves halfway it goes back from where it stopped and noticeably faster. It is a server component with no JavaScript: a CSS transition on translate, and the frame is a size container, so the end offset is calc(100cqh - 100%) with no measuring. Keyboard focus starts the scroll too, and on touch screens a tap focuses the frame.

Browser Support

Container queries (size)

Sizes the screenshot frame.

Your browser:
linear() easing

Shapes the scroll animation.

Your browser:

Preview

Hover the frame, or tap it on a phone.

Installation

npx shadcn@latest add @gooseui/hover-scroll-screenshot
pnpm dlx shadcn@latest add @gooseui/hover-scroll-screenshot
yarn dlx shadcn@latest add @gooseui/hover-scroll-screenshot
bunx --bun shadcn@latest add @gooseui/hover-scroll-screenshot

Usage

import { HoverScrollScreenshot } from "@/components/ui/hover-scroll-screenshot"

export default function Example() {
  return (
    <HoverScrollScreenshot
      src="/screenshots/landing-full.png"
      alt="Landing page"
      className="max-w-md"
    />
  )
}

Examples

Motion variants

Three ways to move. The duration is shared, only the path changes.

glideEven scroll from top to bottom
bounceOvershoots the end and settles
zoomStarts zoomed in, zooms out while scrolling
<HoverScrollScreenshot src={src} alt="Landing" variant="glide" />
<HoverScrollScreenshot src={src} alt="Landing" variant="bounce" />
<HoverScrollScreenshot src={src} alt="Landing" variant="zoom" />

Speed and duration

duration is the time from top to bottom. CSS cannot read the image height, so it does not adapt to the page length: give long screenshots a longer duration.

Slow, 10 seconds
Fixed 3 seconds
<HoverScrollScreenshot src={src} alt="Landing" duration={10000} />
<HoverScrollScreenshot src={src} alt="Landing" duration={3000} returnSpeedup={4} />

Inside a card

Override the frame with className: aspect ratio, border, radius.

Studio landing page

Marketing site, 9 sections

<div className="overflow-hidden rounded-xl border bg-card">
  <HoverScrollScreenshot
    src={src}
    alt="Studio landing page"
    variant="zoom"
    className="aspect-[16/10] rounded-none border-0 border-b"
  />
  <div className="p-4">
    <p className="font-medium">Studio landing page</p>
  </div>
</div>

Props

PropTypeDefaultDescription
srcstring-URL of the tall screenshot
altstring-Image description, also the accessible name of the frame
variant"glide" | "bounce" | "zoom""glide"Motion style
durationnumber6000Scroll time from top to bottom, ms
returnSpeedupnumber6How many times faster the way back is
--hss-easingtiming-functioncubic-bezier(.45,0,.15,1)CSS variable, set via style: easing of the way in. Slow start, long deceleration at the edge
--hss-easing-outtiming-functioncubic-bezier(.3,0,.1,1)CSS variable, set via style: easing of the way back, softens the stop at the top
imageClassNamestring-Classes for the img element
classNamestring-Frame classes; the default ratio is aspect-[4/3]

Features

  • Resumes from the current point: an interrupted scroll reverses from the frame you see, without a jump
  • No JavaScript: hover, focus and transitions do all the work
  • Touch and keyboard: focus with Tab or a tap starts the scroll; moving focus away scrolls back
  • Reduced motion: with prefers-reduced-motion the image stays still