Sleeve Card
A project card lifts and turns in 3D on hover as a View Project tab slides out from behind. Use it on a portfolio page, one card for each project.
npx shadcn@latest add https://impeccable-ui.com/r/sleeve-card.jsonRun it in a project set up with shadcn. No other packages needed. Or open and copy the file into components/ui/sleeve-card.tsx.
Prompts
Paste one into Claude Code, Cursor or any AI coding tool. Install adds this exact card and asks only where it goes. Blend asks three short questions (where and which projects, the colors, and the tab's words and corners), then fits it to your brand without changing how it moves.
# Sleeve Card
A 1-file React component from Impeccable. Add it to this project so it works and looks exactly like the source below, in the one place I choose, and change nothing else.
A project card with a picture, a name and one line of numbers. When I point at it, it rises off the page and turns in 3D, its right edge coming toward me, and a second card slides out from behind it, like a record from its sleeve, with "View Project" written up its edge; a softer third card peeks out between them. The whole card is one link. On a phone the first tap opens it and the second tap follows the link.
## Before you build: one question
Look through this project first: pages that list work, projects, case studies or products (a portfolio or work section, a case study list, a product or template grid), the cards they use now, and where their pictures and links come from. Then ask me this in one message and wait for my answer:
- **Where should it go, and which projects does it show?** Suggest the 1–3 spots it fits best from my code. For each one, name the projects (picture, name, number and link) you would use. I can pick one or name another.
*Why: each card is one door into a project, so it belongs in a list of things people open to see more.*
Ask nothing else. If I say *skip*, use the best suggestion.
## Keep it as it is
The 3D turn and rise with its shadow, the tab that slides out from behind with its label written up the edge, the soft card that peeks between them, and the timing of all three are the design. Keep them exactly as in the source. If something doesn't fit my project, tell me instead of changing it.
- Add only the component file and the one place I picked. If it replaces existing cards there, keep that spot's data and links and remove only the old cards. Don't add packages, change other files, or restyle anything.
- Don't add the demo parts from the Impeccable website: its three item pictures, the gray panel round them, the page reload on click, and the home page's TV.
## Fastest path
If this project has a `components.json` (shadcn), run `npx shadcn@latest add https://impeccable-ui.com/r/sleeve-card.json`.
If the command succeeds, only fix import paths to match this project and skip ahead. If it fails or there is no `components.json`, build it by hand as below.
## Build it
- Stack: React 18 or 19 with TypeScript. No other packages: it moves plain elements with CSS transforms, and its styles sit in a `<style>` tag inside the file.
- JavaScript project? Name the file `sleeve-card.jsx` and remove the type annotations; nothing else changes.
- Create this file, in this project's usual place for components:
- `components/ui/sleeve-card.tsx`
- Keep these exports and their names: `SleeveCard` (also the default export), `SleeveCardProps`, `SleeveCardImage`.
- Keep `"use client"` at the top in Next.js App Router projects. In other setups it is harmless.
- Keep the tuning values at the top exactly as written: `EASE`, `OPEN_MS`, `TAB_DELAY`, `PAD`, `TURN`, `LIFT`, `SHIFT`, `REVEAL`, `TAB_DROP`, `TAB_TILT`, `TAB_SCALE`, `PEEK_REVEAL`, `PEEK_RISE`, `PEEK_SCALE`, `PRESS`, `TUCK`, `SHADOW` and the `CSS` block. They are the design and its timing.
- Keep the link rules: with `href` the whole card is one `<a>` (one stop for the keyboard), with only `onClick` it is one `<button>`. Never put a second link or button inside it.
- Keep the fallbacks: the open state runs on hover only where a real pointer can hover (`@media (hover: hover)`), on keyboard focus, and on a first tap on touch screens (a tap anywhere else closes it). With `prefers-reduced-motion: reduce` nothing turns or slides: the tab fades in at its place. The picture loads lazily and can't be dragged out.
## Use it
```tsx
import { SleeveCard } from "@/components/ui/sleeve-card";
export function Work() {
return (
<div className="grid grid-cols-1 gap-12 sm:grid-cols-3 sm:gap-x-16">
<SleeveCard
href="/work/nova"
image={{ src: "/work/nova.webp", alt: "Nova app on a phone" }}
title="Nova"
stat="6.2%"
statLabel="Average engagement rate"
/>
{/* one card per project */}
</div>
);
}
```
- Each card fills the width it is given. Leave about a quarter of a card's width free on its right (the column gap), or the open tab covers the next card.
- Pictures are shown nearly square (1 by 1.04) and cropped to fill. Keep each file small (about twice the size it shows, WebP), with real `alt` text. Pictures from another domain must be allowed by the project's Content-Security-Policy (`img-src`).
- Use the project's own link component only if plain `href` breaks its routing; then pass `onClick` and navigate there instead.
## How the card works
Read this before you touch anything, so you know what the code does and why it must stay as it is.
1. **Three cards in one.** The card you see sits on top. Behind it, the same size, sit the tab (the accent color, with the label written up its edge) and a softer card between them. At rest both are tucked 4% inside and a little smaller, so no colored edge shows round the corners.
2. **It opens.** On hover, focus or a first tap, the top card turns 16 degrees round its middle, so its right edge comes toward you, rises 26px toward you through a 900px perspective, and steps 4% of its width to the left. Its shadow grows and falls to the lower left. All of it takes 0.62 seconds with a quick start and a long soft landing.
3. **The tab slides out.** 50ms later the tab slides 24% of the card's width to the right, drops 4%, leans 3 degrees and sits at 90% size, so it looks further back. The label sits in the part that shows, reading bottom to top, in capitals. The soft card slides 13% right and 3% up at 95% size, so a sliver of it peeks out above the tab.
4. **It closes.** When the pointer leaves, everything slides back in one motion with the same curve.
5. **The press.** Pressing the open card makes it give to 97% for a moment, so a click feels physical.
6. **Room.** The tab sticks out about a quarter of the card's width to the right, so each card needs that much free space on its right (the gap in a grid). The open card rises above its neighbours.
7. **Colors.** The card takes `--card` from the theme (else the page background), and the text takes `--foreground` (else `--fg`), so it follows light and dark mode. The tab is `accent`, with `accentText` on it; the soft card is `peek`. Text sizes follow the card's own width, so a small card has small text. Only transforms and shadows change while it moves.
## Check
- It type-checks and the page renders with no console errors.
- Pointing at a card makes it turn and rise in about 0.6 seconds while the "View Project" tab slides out on its right, and moving away slides it all back. Clicking anywhere on the card follows its link. Tab moves focus card by card, and a focused card opens.
- It looks right in light and dark mode (check both): the card, its text and its shadow read well on each background, and no colored edge shows round a closed card.
- It works with a finger on a phone: the first tap opens a card, the second tap follows the link, a tap elsewhere closes it, and nothing scrolls sideways.
- With `prefers-reduced-motion: reduce`, nothing turns or slides: the tab fades in at its place.
- Nothing else on the site looks or behaves differently.
- Finish with a short report: the files you added or changed, where it's placed, and every place where you had to do something differently from the source, and why.
## Source
The reference implementation. Copy it as-is, then apply only the changes listed above.
### `components/ui/sleeve-card.tsx`
```tsx
"use client";
/**
* Sleeve Card, from Impeccable.
*
* A project card that lifts and turns in 3D under the pointer, and a second card
* slides out from behind it, like a record from its sleeve, with "View Project"
* written down its edge. A third, softer card peeks out between them. Give it an
* `href` and the whole card is one link, or an `onClick` and it is one button.
*
* Mouse: hover or focus opens it. Touch: the first tap opens it, the second tap
* follows the link, a tap anywhere else closes it. Reduced motion: no turn, the
* tab just fades in.
*
* Colors come from your theme: the card from --card (else --background / --bg),
* the text from --foreground (else --fg), so it follows light and dark mode.
* One file, React only, CSS transforms, no packages.
*/
import {
useEffect,
useRef,
useState,
type CSSProperties,
type MouseEvent as ReactMouseEvent,
type ReactNode,
} from "react";
export type SleeveCardImage = {
/** Picture address. Same site, or a site your Content-Security-Policy allows. */
src: string;
/** Says what the picture shows. Read by screen readers. */
alt: string;
};
export type SleeveCardProps = {
/** The picture at the top of the card. Shown nearly square (1 by 1.04). */
image: SleeveCardImage;
/** The project name under the picture. */
title: ReactNode;
/** A number in the line under the title, like "6.2%". */
stat?: ReactNode;
/** The words after the number, like "Average engagement rate". */
statLabel?: ReactNode;
/** Written down the card that slides out. Shown in capitals. */
label?: string;
/** Where the card goes. The whole card becomes one link. */
href?: string;
/** Link target, like "_blank" (then rel="noopener noreferrer" is added). */
target?: string;
/** Runs on click (after the first tap on touch screens, which only opens it). Without `href` the card is a button. */
onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
/** Keep it open. Leave it out and it opens on hover, focus or a first tap. */
open?: boolean;
/** Color of the sliding card. Any CSS color or var(--…). */
accent?: string;
/** Text color on the accent. */
accentText?: string;
/** Color of the card that peeks out between them. Any CSS color or var(--…). */
peek?: string;
/** Corner radius of the card, in px. The picture inside follows it. */
radius?: number;
className?: string;
style?: CSSProperties;
};
/* ---------- the design: keep as written ---------- */
const EASE = "cubic-bezier(.22,1,.36,1)"; // quick start, long soft landing
const OPEN_MS = 620; // the card turns and the tab slides out
const TAB_DELAY = 50; // the tab leaves a beat after the card starts to turn
const PAD = 6; // px between the card edge and the picture
const TURN = -16; // deg: the card turns so its right edge comes toward you
const LIFT = 26; // px: and it rises off the page toward you
const SHIFT = -4; // % of its width: it steps left to make room for the tab
const REVEAL = 24; // % of the card width the tab slides out to the right
const TAB_DROP = 4; // % of the card height the tab sits lower
const TAB_TILT = 3; // deg: the tab leans a little
const TAB_SCALE = 0.9; // the tab sits further back, so it looks smaller
const PEEK_REVEAL = 13; // % the middle card slides out
const PEEK_RISE = -3; // % the middle card sits higher
const PEEK_SCALE = 0.95;
const PRESS = 0.97; // the card gives a little under a press
const TUCK = "translateX(-4%) scale(.92)"; // at rest the cards behind sit fully inside, so no colored edge shows
/** Default colors: a soft lavender tab, a sage card between, both mixed into your page in dark mode. */
const ACCENT = "#a48bf7";
const ACCENT_TEXT = "#1a1233";
const PEEK = "color-mix(in oklab, #b7c6aa 72%, var(--slc-bg))";
const CSS = `
.slc { --slc-fg: var(--foreground, var(--fg, CanvasText)); --slc-bg: var(--background, var(--bg, Canvas)); --slc-card: var(--card, var(--panel, var(--slc-bg)));
position: relative; display: block; width: 100%; box-sizing: border-box; container-type: inline-size; color: var(--slc-fg); text-decoration: none; text-align: start;
font: inherit; margin: 0; padding: 0; border: 0; background: none; outline: none; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
.slc[data-link="true"] { cursor: pointer; }
.slc:focus-visible .slc-card { box-shadow: 0 0 0 2px var(--slc-card), 0 0 0 4px color-mix(in oklab, var(--slc-fg) 55%, transparent), var(--slc-shadow-open); }
.slc-card { position: relative; z-index: 2; display: block; box-sizing: border-box; height: 100%; padding: ${PAD}px; border-radius: var(--slc-r); background: var(--slc-card);
box-shadow: var(--slc-shadow); transform: perspective(900px); transition: transform ${OPEN_MS}ms ${EASE}, box-shadow ${OPEN_MS}ms ${EASE}; backface-visibility: hidden; }
.slc-pic { position: relative; display: block; overflow: hidden; aspect-ratio: 1 / 1.04; border-radius: max(0px, calc(var(--slc-r) - ${PAD}px)); background: color-mix(in oklab, var(--slc-fg) 6%, var(--slc-card)); }
.slc-pic img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.slc-body { display: block; padding: clamp(8px, 4.6cqi, 14px) clamp(4px, 2.6cqi, 8px) clamp(4px, 2.2cqi, 8px); }
.slc-title { display: block; font-size: clamp(12px, 6.2cqi, 19px); font-weight: 500; line-height: 1.25; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slc-meta { display: block; margin-top: .35em; font-size: clamp(10px, 4.3cqi, 13px); line-height: 1.35; color: color-mix(in oklab, var(--slc-fg) 58%, transparent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slc-stat { color: color-mix(in oklab, var(--slc-fg) 78%, transparent); font-variant-numeric: tabular-nums; margin-right: .55em; }
.slc-back { position: absolute; inset: 0; display: block; border-radius: var(--slc-r); transform-origin: 100% 50%; transform: ${TUCK}; transition: transform ${OPEN_MS}ms ${EASE}; }
.slc-peek { z-index: 0; background: var(--slc-peek); }
.slc-tab { z-index: 1; background: var(--slc-accent); color: var(--slc-on-accent); box-shadow: 0 10px 24px -14px rgba(0,0,0,.35); }
.slc-label { position: absolute; top: 9%; right: calc(${REVEAL / 2}% / ${TAB_SCALE}); max-height: 82%; transform: translateX(50%) rotate(180deg); writing-mode: vertical-rl;
font-size: clamp(9px, 4.2cqi, 13px); font-weight: 600; letter-spacing: .08em; line-height: 1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Open: the card turns toward you and rises, the tab and the middle card slide out from behind. */
.slc[data-open="true"], .slc:focus-visible { z-index: 3; }
.slc[data-open="true"] .slc-card, .slc:focus-visible .slc-card { transform: perspective(900px) translateX(${SHIFT}%) translateZ(${LIFT}px) rotateY(${TURN}deg); box-shadow: var(--slc-shadow-open); }
.slc[data-open="true"] .slc-tab, .slc:focus-visible .slc-tab { transform: translate(${REVEAL}%, ${TAB_DROP}%) rotate(${TAB_TILT}deg) scale(${TAB_SCALE}); transition-delay: ${TAB_DELAY}ms; }
.slc[data-open="true"] .slc-peek, .slc:focus-visible .slc-peek { transform: translate(${PEEK_REVEAL}%, ${PEEK_RISE}%) scale(${PEEK_SCALE}); }
.slc[data-link="true"][data-pressed="true"] .slc-card { transform: perspective(900px) translateX(${SHIFT}%) translateZ(${LIFT}px) rotateY(${TURN}deg) scale(${PRESS}); transition-duration: 160ms; }
@media (hover: hover) {
.slc:hover { z-index: 3; }
.slc:hover .slc-card { transform: perspective(900px) translateX(${SHIFT}%) translateZ(${LIFT}px) rotateY(${TURN}deg); box-shadow: var(--slc-shadow-open); }
.slc:hover .slc-tab { transform: translate(${REVEAL}%, ${TAB_DROP}%) rotate(${TAB_TILT}deg) scale(${TAB_SCALE}); transition-delay: ${TAB_DELAY}ms; }
.slc:hover .slc-peek { transform: translate(${PEEK_REVEAL}%, ${PEEK_RISE}%) scale(${PEEK_SCALE}); }
}
/* Reduced motion: nothing turns or slides, the tab simply fades in at its place. */
@media (prefers-reduced-motion: reduce) {
.slc .slc-card { transform: none !important; transition: box-shadow .2s linear; }
.slc .slc-back { transform: translate(${REVEAL}%, 0) scale(${TAB_SCALE}) !important; opacity: 0; visibility: hidden; transition: opacity .2s linear, visibility 0s .2s; }
.slc .slc-peek { display: none; }
.slc[data-open="true"] .slc-tab, .slc:focus-visible .slc-tab { opacity: 1; visibility: visible; transition: opacity .2s linear; }
}
@media (prefers-reduced-motion: reduce) and (hover: hover) {
.slc:hover .slc-tab { opacity: 1; visibility: visible; transition: opacity .2s linear; }
}`;
/** Card shadows: a hairline edge and a soft drop, deeper once it rises. Stronger on a dark page. */
const SHADOW = {
rest: "0 0 0 1px color-mix(in oklab, var(--slc-fg) 7%, transparent), 0 1px 2px rgba(0,0,0,.06), 0 10px 24px -14px rgba(0,0,0,.22)",
open: "0 0 0 1px color-mix(in oklab, var(--slc-fg) 7%, transparent), 0 2px 4px rgba(0,0,0,.06), -14px 28px 48px -18px rgba(0,0,0,.32)",
};
export function SleeveCard({
image,
title,
stat,
statLabel,
label = "View Project",
href,
target,
onClick,
open,
accent = ACCENT,
accentText = ACCENT_TEXT,
peek = PEEK,
radius = 14,
className,
style,
}: SleeveCardProps) {
const rootRef = useRef<HTMLElement>(null);
const imgRef = useRef<HTMLImageElement>(null);
const touch = useRef(false); // the last press was a finger
const [tapped, setTapped] = useState(false); // opened by a first tap
const [pressed, setPressed] = useState(false);
const [broken, setBroken] = useState<string | null>(null); // a picture that failed to load: show the soft placeholder instead
const interactive = !!(href || onClick);
// A picture that failed before the page woke up never fires onError, so check it once here.
useEffect(() => {
const img = imgRef.current;
if (img?.complete && img.naturalWidth === 0) setBroken(image.src);
}, [image.src]);
// A tap anywhere else closes a card opened by a tap.
useEffect(() => {
if (!tapped) return;
const away = (e: PointerEvent) => {
if (!rootRef.current?.contains(e.target as Node)) setTapped(false);
};
document.addEventListener("pointerdown", away);
return () => document.removeEventListener("pointerdown", away);
}, [tapped]);
const handleClick = (e: ReactMouseEvent<HTMLElement>) => {
// On a touch screen there is no hover, so the first tap only opens it.
if (touch.current && !tapped && !open) {
e.preventDefault();
setTapped(true);
return;
}
onClick?.(e);
};
const content = (
<>
<style>{CSS}</style>
<span className="slc-back slc-peek" aria-hidden="true" />
<span className="slc-back slc-tab">
<span className="slc-label">{label}</span>
</span>
<span className="slc-card">
<span className="slc-pic">
{broken !== image.src && (
// eslint-disable-next-line @next/next/no-img-element -- one plain picture, any source
<img ref={imgRef} src={image.src} alt={image.alt} loading="lazy" decoding="async" draggable={false} onError={() => setBroken(image.src)} />
)}
</span>
<span className="slc-body">
<span className="slc-title">{title}</span>
{(stat != null || statLabel != null) && (
<span className="slc-meta">
{stat != null && <span className="slc-stat">{stat}</span>}
{statLabel}
</span>
)}
</span>
</span>
</>
);
const shared = {
className: `slc${className ? ` ${className}` : ""}`,
"data-open": open || tapped ? "true" : "false",
"data-link": interactive ? "true" : "false",
"data-pressed": pressed ? "true" : "false",
"aria-label": typeof title === "string" ? `${label.trim()}: ${title}` : undefined,
style: {
"--slc-r": `${radius}px`,
"--slc-accent": accent,
"--slc-on-accent": accentText,
"--slc-peek": peek,
"--slc-shadow": SHADOW.rest,
"--slc-shadow-open": SHADOW.open,
...style,
} as CSSProperties,
onPointerDown: (e: React.PointerEvent) => {
touch.current = e.pointerType === "touch";
if (interactive && e.button === 0) setPressed(true);
},
onPointerUp: () => setPressed(false),
onPointerLeave: () => setPressed(false),
onPointerCancel: () => setPressed(false),
onBlur: () => setTapped(false),
onClick: handleClick,
};
if (href) {
return (
<a
ref={rootRef as React.Ref<HTMLAnchorElement>}
href={href}
target={target}
rel={target === "_blank" ? "noopener noreferrer" : undefined}
draggable={false}
{...shared}
>
{content}
</a>
);
}
if (onClick) {
return (
<button ref={rootRef as React.Ref<HTMLButtonElement>} type="button" {...shared}>
{content}
</button>
);
}
return (
<div ref={rootRef as React.Ref<HTMLDivElement>} {...shared} aria-label={undefined}>
{content}
</div>
);
}
export default SleeveCard;
```
Usage
Give each card a picture, a title and an href. Leave room on the right of each card for the tab.
import { SleeveCard } from "@/components/ui/sleeve-card";
export function Work() {
return (
<div className="grid grid-cols-1 gap-12 sm:grid-cols-3 sm:gap-x-16">
<SleeveCard
href="/work/nova"
image={{ src: "/work/nova.webp", alt: "Nova app on a phone" }}
title="Nova"
stat="6.2%"
statLabel="Average engagement rate"
/>
{/* more cards */}
</div>
);
}Keep each picture small (about twice the size it shows, WebP). Pictures load only when they come near the screen.
How it moves
A card that turns toward you, and a second card that slides out of it like a record from its sleeve.
Point at the card and it rises off the page and turns, its right edge coming toward you, while it steps a little to the left. A beat later the tab slides out from behind it, leaning a little, with View Project written up its edge, and a softer card peeks out between them. Its shadow grows as it rises. Move away and it all slides back in one smooth motion. Pressing it makes it give a little.
The whole card is one link, so it is one stop for the keyboard, and focusing it opens it too. Touch screens have no hover, so the first tap opens it, the second tap follows the link, and a tap anywhere else closes it. With reduced motion nothing turns or slides: the tab simply fades in.
Props
| Prop | Default | What it does |
|---|---|---|
image | — | The picture: { src, alt }. Shown nearly square. alt is read by screen readers. |
title | — | The project name under the picture. |
stat / statLabel | — | The line under the title: a number, then a few words. |
href | — | Where the card goes. The whole card is one link. |
target | — | Link target. "_blank" also adds rel="noopener noreferrer". |
onClick | — | Runs on click. Without href the card is a button. On touch screens the first tap only opens it. |
label | "View Project" | Written down the card that slides out, in capitals. |
open | — | true keeps it open. Leave it out and it opens on hover, focus or a first tap. |
accent / accentText | lavender / ink | The sliding card, and the text on it. Any CSS color or token. |
peek | soft sage | The card that peeks out between them. Any CSS color or token. |
radius | 14 | Card corners in px. The picture inside follows: inner radius = outer radius minus the 6px padding. |
className / style | — | On the card. It fills its width; keep about a quarter of its width free on its right for the tab. |