Zoom Card
Media frame whose content zooms slowly on hover, with an optional caption.
$npx shadcn@latest add https://framebrick.co/r/zoom-card.jsonFrom the Nitip template, see it in context.
import { ZoomCard } from "@/components/ui/zoom-card";
// Demo photos from Unsplash (free under the Unsplash License), served by this site so no request leaves it.
const cards = [
{ title: "Aurora — brand site", image: "/demo/zoom-card-aurora.webp", alt: "White curved facade of a modern building" },
{ title: "Kestrel — product launch", image: "/demo/zoom-card-kestrel.webp", alt: "Calm living room with a low grey sofa" },
];
export default function ZoomCardDemo() {
return (
<div className="grid w-full max-w-xl gap-4 sm:grid-cols-2">
{cards.map((card) => (
<ZoomCard key={card.title} href="#" caption={card.title} className="aspect-[4/3]">
<img src={card.image} alt={card.alt} className="object-cover" />
</ZoomCard>
))}
</div>
);
}Examples
Greyscale
The photos rest at half grey and take their colour on hover and keyboard focus; they do not grow.
import { ZoomCard } from "@/components/ui/zoom-card";
// Demo photos from Unsplash (free under the Unsplash License), served by this site so no request leaves it.
const cards = [
{ title: "Harbour — photo series", image: "/demo/slideshow-harbour.webp", alt: "Fishing boats reflected in a still harbour" },
{ title: "Long exposure — print set", image: "/demo/slideshow-long-exposure.webp", alt: "Smooth sea under a golden evening sky" },
];
/* The photos rest at half grey and take their colour on hover and keyboard focus; they do not grow. */
export default function ZoomCardGrayscaleDemo() {
return (
<div className="grid w-full max-w-xl gap-4 sm:grid-cols-2">
{cards.map((card) => (
<ZoomCard key={card.title} href="#" caption={card.title} grayscale={0.5} zoom={1} className="aspect-[4/3]">
<img src={card.image} alt={card.alt} className="object-cover" />
</ZoomCard>
))}
</div>
);
}<ZoomCard href="/work/harbour" grayscale={0.5} zoom={1} caption="Harbour">…</ZoomCard>Ease-in
The photo settles from 105% to 100% on an ease-in: it barely moves at first, then arrives.
import { ZoomCard } from "@/components/ui/zoom-card";
// Demo photos from Unsplash (free under the Unsplash License), served by this site so no request leaves it.
const cards = [
{ title: "Aurora — brand site", image: "/demo/zoom-card-aurora.webp", alt: "White curved facade of a modern building" },
{ title: "Kestrel — product launch", image: "/demo/zoom-card-kestrel.webp", alt: "Calm living room with a low grey sofa" },
];
export default function ZoomCardEaseInDemo() {
return (
<div className="grid w-full max-w-xl gap-4 sm:grid-cols-2">
{cards.map((card) => (
<ZoomCard key={card.title} href="#" rest={1.05} zoom={1} ease="in" caption={card.title} className="aspect-[4/3]">
<img src={card.image} alt={card.alt} className="object-cover" />
</ZoomCard>
))}
</div>
);
}<ZoomCard href="/work/aurora" rest={1.05} zoom={1} ease="in" caption="Aurora — brand site">…</ZoomCard>Installation
$ npx shadcn@latest add https://framebrick.co/r/zoom-card.json1. Install the dependencies.
npm install motion clsx tailwind-merge2. Add
cn()tolib/utils.ts(skip if shadcn already created it).import { clsx, type ClassValue } from "clsx"; import { extendTailwindMerge } from "tailwind-merge"; /* tailwind-merge must know the site's type scale (globals.css) is a font size, not a text color — otherwise cn("text-h6 text-muted-foreground") drops text-h6. */ const twMerge = extendTailwindMerge({ extend: { classGroups: { "font-size": [{ text: ["display", "h1", "h2", "h3", "h4", "h5", "h6"] }] } }, }); export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }3. Copy the component into
components/ui/zoom-card.tsx."use client"; import * as React from "react"; import Link from "next/link"; import { cn } from "@/lib/utils"; /* * Zoom Card — a media frame whose content zooms slowly on hover (from the Nitip project and post cards). * A `rest` above `zoom` reverses it — the image sits enlarged and settles as you point at it, as Titen's project * cards and Findit's city cards do. * Put an image, a video or anything else inside; the frame clips it. An optional caption sits over the bottom of the * frame on a gradient, and the whole card can be a link. * The zoom uses Framer's own tween — cubic-bezier(0.12, 0.23, 0.5, 1) over 400 ms — not a spring. `ease="in"` is Cerette's * project cards: the same 400 ms on an ease-in, cubic-bezier(0.5, 0, 0.88, 0.77), so the photo has barely moved at 117ms. * * `grayscale` (0 to 1, default 0) is from Brickfolio's project and post cards (and Marai Neesu's product card): the photo sits at * that much grey (Brickfolio: 0.5) and takes its full colour on hover and keyboard focus, at the same time as the zoom (Framer: spring * 500 / 60, the photo does not grow there; the tween stands in, as it does for the zoom, since springs were ruled out for this * component). The filter is on the photo's own layer, not the frame, so the caption stays white. Filter is not a transform, so * <MotionConfig> would not skip it, but this is plain CSS with motion-reduce:transition-none, which covers the filter too: with * reduced motion the colour changes at once. At 0 nothing is added: the markup and classes are as they were. * * Pairs with <LabelCursor />: pass `cursor="View project"` to show a label while the pointer is over the card. */ export type ZoomCardProps = { children: React.ReactNode; href?: string; /** Shown over the bottom of the frame, and it names the link for a screen reader. */ caption?: React.ReactNode; /** Name of the link when there is no caption and the media's alt text is empty. */ label?: string; /** Scale at the end of the hover, e.g. 1.05 = 105%. */ zoom?: number; /** Scale at rest. Above `zoom` (1.05 against 1) it runs the other way: the image settles as you point at it. */ rest?: number; /** How grey the photo is at rest, from 0 (default) to 1; it takes its colour on hover and keyboard focus. */ grayscale?: number; /** "out" (default) starts fast and settles; "in" starts slowly and ends fast. */ ease?: "out" | "in"; /** Label for <LabelCursor /> (sets data-cursor). */ cursor?: string; className?: string; }; export function ZoomCard({ children, href, caption, label, zoom = 1.05, rest = 1, grayscale = 0, ease = "out", cursor, className }: ZoomCardProps) { const frameProps = { "data-cursor": cursor, style: { ["--zoom" as string]: zoom, ["--rest" as string]: rest, ["--zoom-ease" as string]: ease === "in" ? "cubic-bezier(0.5,0,0.88,0.77)" : "cubic-bezier(0.12,0.23,0.5,1)", ...(grayscale > 0 ? { ["--gray" as string]: grayscale } : {}), }, className: cn( "group relative block overflow-hidden rounded-lg bg-muted outline-none", href && "focus-visible:ring-[3px] focus-visible:ring-ring/50", className, ), }; const content = ( <> <div className={cn( "size-full scale-(--rest) transition-transform duration-400 ease-(--zoom-ease) group-hover:scale-(--zoom) group-focus-visible:scale-(--zoom) motion-reduce:transition-none *:size-full", grayscale > 0 && "grayscale-(--gray) transition-[transform,filter] group-hover:grayscale-0 group-focus-visible:grayscale-0", )} > {children} </div> {caption && ( <div className="pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-4 text-sm font-medium text-white"> {caption} </div> )} </> ); /* A link holding only a picture has no name: the caption gives it one, otherwise `label` must. */ return href ? ( <Link href={href} aria-label={label} {...frameProps}> {content} </Link> ) : ( <div {...frameProps}>{content}</div> ); }
Usage
import { ZoomCard } from "@/components/ui/zoom-card";
<ZoomCard href="/work/aurora" caption="Aurora — brand site" cursor="View project" className="aspect-[4/3]">
<Image src={cover} alt="" fill className="object-cover" />
</ZoomCard>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | The media: an image, a video, anything. It is stretched to the frame and clipped. |
| href | string | — | Makes the whole card a Next.js link. |
| caption | ReactNode | — | Shown over the bottom of the frame on a gradient; it also names the link. |
| label | string | — | Names the link when there is no caption and the media's alt text is empty. |
| zoom | number | 1.05 | Scale at the end of the hover. |
| rest | number | 1 | Scale at rest. Above `zoom` (1.05 against 1) it runs the other way: the image sits enlarged and settles as you point at it. |
| grayscale | number | 0 | How grey the photo is at rest, from 0 to 1 (Brickfolio: 0.5). It takes its full colour on hover and keyboard focus. Put zoom={1} to keep the photo from growing. |
| ease | "out" | "in" | "out" | The curve of the hover: "out" starts fast and settles (cubic-bezier(0.12, 0.23, 0.5, 1)); "in" starts slowly and ends fast (cubic-bezier(0.5, 0, 0.88, 0.77), Cerette). Both take 400 ms. |
| cursor | string | — | Label for <LabelCursor /> (sets data-cursor). |
- grayscale is Brickfolio's project and post cards (and Marai Neesu's product card, grey 50% to full colour with a 105% zoom): the photo sits at that much grey and takes its colour on hover and keyboard focus at the same time as the zoom; in Brickfolio it does not grow (zoom={1}). Framer runs it on spring 500 / 60; the 400 ms tween of this component stands in, as it does for the zoom. The filter is on the photo's own layer, not the frame, so the caption stays white. Filter is not a transform, so MotionConfig would not skip it, but this is plain CSS with motion-reduce:transition-none, which covers the filter too: with reduced motion the colour changes at once. At 0 nothing is added, and the markup and classes are as they were.
- ease="in" is Cerette's project cards (105% to 100%, 400 ms ease-in): at 117 ms Framer's photo has barely moved (283.5 to 282.6 px of 270), where the ease-out is more than half way.
- The zoom uses Framer's own tween — cubic-bezier(0.12, 0.23, 0.5, 1) over 400 ms — not a spring.
- Keyboard focus zooms too; reduced motion turns the transition off.
AI prompt
Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.
Create a React + Tailwind CSS component called ZoomCard (no animation library needed). - A rounded-lg frame with overflow-hidden and bg-muted that stretches its children to fill it. - A grayscale prop (0 to 1, default 0): above 0 the inner layer also has grayscale-(--gray) with --gray set inline, transition-[transform,filter], and group-hover:grayscale-0 and group-focus-visible:grayscale-0, so the photo takes its colour with the zoom; at 0 add nothing. The caption is outside that layer, so it stays white. motion-reduce:transition-none covers the filter. - On hover or keyboard focus of the frame, the inner layer scales to 1.05 with transition-transform, duration 400ms and Framer's tween cubic-bezier(0.12, 0.23, 0.5, 1); motion-reduce turns the transition off. - Optional caption absolutely positioned across the bottom on a gradient from black/70 to transparent, p-4, text-sm font-medium text-white, pointer-events-none. - If an href is given, the frame is a Next.js Link with a visible focus ring; a "cursor" prop sets data-cursor for a custom cursor component.















