Hover Preview

Cursor Image Preview for React

A list of names that opens a photo at the pointer. It trails the cursor with a little weight, leans as it moves, and wipes to the next photo from the direction you travel, like flipping through prints.

  • List
  • Image
  • Motion

Uses motion, clsx, tailwind-merge

Open in ChatGPTOpen in Claude
tilt5°
stiffness150
damping18
speed1.00×
<HoverPreview />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Hover Preview: A list of names that opens a photo at the pointer. It trails the cursor with a little weight, leans as it moves, and wipes to the next photo from the direction you travel, like flipping through prints.

1. Install it:
   npx shadcn@latest add @keyframeui/hover-preview-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/hover-preview-demo.json instead.)
   It adds the demo, components/hover-preview-demo.tsx, and the component, components/ui/hover-preview.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <HoverPreview> on its own.

3. These props set its feel. Change them before you change the file:
   - tilt (default 5): The most degrees the photo leans while it moves, toward the way it's going. It straightens as it catches up. `0` keeps it upright.
   - stiffness (default 150): Spring stiffness of the photo trailing the pointer. Higher keeps it close; lower lets it fall further behind.
   - damping (default 18): Spring damping of the photo trailing the pointer. Lower lets it swing past the pointer before it settles.
   - speed (default 1): How fast the photo opens, closes and wipes to the next one, as a multiple of the default pace. `2` is twice as fast.

4. Don't change, in components/ui/hover-preview.tsx:
   - The photo is one element moved by `x`/`y` springs and leaned by a `rotate` from their velocity, so the pointer never renders React; rows subscribe to their own state, so only changed rows do.
   - Opens, closes and wipes are WAAPI animations of `clip-path` and `transform` only, aimed at the point where the pointer falls on the photo, so it opens from and closes into that point.
   - A photo joins the stack only once it's downloaded and decoded, and its wipe starts in a layout effect, so a wipe never shows a blank or un-wiped frame.
   - The next photo wipes in from the way you moved: down the list from the top, up from the bottom.
   - Reduced motion opens the photo where you point and holds it there (keyboard focus and far rows jump it); it crossfades, and nothing trails or leans.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/hover-preview.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/hover-preview.tsx and installs motion, clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/hover-preview

Examples

Finished sections built with Hover Preview. Each one installs whole, with the component included.

Team

Names and roles, with a portrait on hover. The frame is taller and rounder, and leans a little less.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Hover Preview: A list of names that opens a photo at the pointer. It trails the cursor with a little weight, leans as it moves, and wipes to the next photo from the direction you travel, like flipping through prints.
This demo, Team: Names and roles, with a portrait on hover. The frame is taller and rounder, and leans a little less.

1. Install it:
   npx shadcn@latest add @keyframeui/hover-preview-team-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/hover-preview-team-demo.json instead.)
   It adds the demo, components/hover-preview-team-demo.tsx, and the component, components/ui/hover-preview.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <HoverPreview> on its own.

3. These props set its feel. Change them before you change the file:
   - tilt (default 5): The most degrees the photo leans while it moves, toward the way it's going. It straightens as it catches up. `0` keeps it upright.
   - stiffness (default 150): Spring stiffness of the photo trailing the pointer. Higher keeps it close; lower lets it fall further behind.
   - damping (default 18): Spring damping of the photo trailing the pointer. Lower lets it swing past the pointer before it settles.
   - speed (default 1): How fast the photo opens, closes and wipes to the next one, as a multiple of the default pace. `2` is twice as fast.

4. Don't change, in components/ui/hover-preview.tsx:
   - The photo is one element moved by `x`/`y` springs and leaned by a `rotate` from their velocity, so the pointer never renders React; rows subscribe to their own state, so only changed rows do.
   - Opens, closes and wipes are WAAPI animations of `clip-path` and `transform` only, aimed at the point where the pointer falls on the photo, so it opens from and closes into that point.
   - A photo joins the stack only once it's downloaded and decoded, and its wipe starts in a layout effect, so a wipe never shows a blank or un-wiped frame.
   - The next photo wipes in from the way you moved: down the list from the top, up from the bottom.
   - Reduced motion opens the photo where you point and holds it there (keyboard focus and far rows jump it); it crossfades, and nothing trails or leans.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/hover-preview.md

Journal

An archive of essays with dates and reading times. Each title shows its cover image in a wide 3:2 frame.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Hover Preview: A list of names that opens a photo at the pointer. It trails the cursor with a little weight, leans as it moves, and wipes to the next photo from the direction you travel, like flipping through prints.
This demo, Journal: An archive of essays with dates and reading times. Each title shows its cover image in a wide 3:2 frame.

1. Install it:
   npx shadcn@latest add @keyframeui/hover-preview-journal-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/hover-preview-journal-demo.json instead.)
   It adds the demo, components/hover-preview-journal-demo.tsx, and the component, components/ui/hover-preview.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <HoverPreview> on its own.

3. These props set its feel. Change them before you change the file:
   - tilt (default 5): The most degrees the photo leans while it moves, toward the way it's going. It straightens as it catches up. `0` keeps it upright.
   - stiffness (default 150): Spring stiffness of the photo trailing the pointer. Higher keeps it close; lower lets it fall further behind.
   - damping (default 18): Spring damping of the photo trailing the pointer. Lower lets it swing past the pointer before it settles.
   - speed (default 1): How fast the photo opens, closes and wipes to the next one, as a multiple of the default pace. `2` is twice as fast.

4. Don't change, in components/ui/hover-preview.tsx:
   - The photo is one element moved by `x`/`y` springs and leaned by a `rotate` from their velocity, so the pointer never renders React; rows subscribe to their own state, so only changed rows do.
   - Opens, closes and wipes are WAAPI animations of `clip-path` and `transform` only, aimed at the point where the pointer falls on the photo, so it opens from and closes into that point.
   - A photo joins the stack only once it's downloaded and decoded, and its wipe starts in a layout effect, so a wipe never shows a blank or un-wiped frame.
   - The next photo wipes in from the way you moved: down the list from the top, up from the bottom.
   - Reduced motion opens the photo where you point and holds it there (keyboard focus and far rows jump it); it crossfades, and nothing trails or leans.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/hover-preview.md

Props

image Required

Typestring

HoverPreviewItem: the photo that opens while the row is pointed at or focused. Every photo is fetched once the list nears the screen, and each shows only once it's decoded, so a wipe never shows a blank frame.

href

Typestring

HoverPreviewItem: where the row links. Each row is an <a>, and other anchor props pass through to it.

thumbnail

Typestring

HoverPreviewItem: a smaller copy of image. Touch screens can't hover, so they show it as a thumbnail in the row instead. Defaults to image. Devices that can hover never download it.

thumbnailClassName

Typestring

HoverPreviewItem: classes for the touch-screen thumbnail, which defaults to size-12 rounded-md.

className

Typestring

HoverPreviewItem: classes for the row, which defaults to flex items-center gap-4. While another row shows, its direct children fade to 30% and the row's own border stays put; change that with data-[state=dimmed]:*:opacity-50. HoverPreview also takes className and other div props for its wrapper, and the photo stays inside that box.

previewClassName

TypestringDefault"aspect-[4/3] w-72 rounded-lg"

HoverPreview: size, shape and rounding of the floating photo.

tilt

TypenumberDefault5

HoverPreview: the most degrees the photo leans while it moves, toward the way it's going. It straightens as it catches up. 0 keeps it upright.

stiffness

TypenumberDefault150

HoverPreview: spring stiffness of the photo trailing the pointer. Higher keeps it close; lower lets it fall further behind.

damping

TypenumberDefault18

HoverPreview: spring damping of the photo trailing the pointer. Lower lets it swing past the pointer before it settles.

speed

TypenumberDefault1

HoverPreview: how fast the photo opens, closes and wipes to the next one, as a multiple of the default pace. 2 is twice as fast.