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.

  • List
  • Image
  • Motion

Uses motion, clsx, tailwind-merge

Open in ChatGPTOpen in Claude

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.

Journal

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

Props

imageRequired

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.