Flip cardPro
A two-sided card that flips in 3D on click, Enter or hover.
Pro
$12/mo
Click to see what's included
Ada Lovelace
When to use
- Reveal details on demand: plan features, flashcards, contact cards.
When not to use
- Content that must be compared side by side: show both faces.
- Faces containing form fields or buttons: use a dialog.
Installation
Usage
Import it from @/components/ui/flip-card after installing.
example.tsx
import { FlipCard } from "@/components/ui/flip-card";
export function PlanCard() {
return (
<FlipCard
label="Pro plan"
className="h-72 w-60"
front={<div className="p-5">Pro · $12/mo</div>}
back={<ul className="p-5">…features</ul>}
/>
);
}API reference
FlipCard
Two absolutely positioned faces in a 3D container. Size it with className.
| Prop | Type | Default | Description |
|---|---|---|---|
| front / back | ReactNode | – | The two faces; keep them non-interactive. |
| label | string | – | Names the card; the current face is appended. |
| trigger | "click" | "hover" | "click" | Click (and Enter or Space) or hover and focus. |
| axis | "x" | "y" | "y" | Flip around the vertical or horizontal axis. |
| flipped / defaultFlipped / onFlippedChange | boolean | – | Controlled or uncontrolled state. |
Keyboard interactions
| Keys | Action |
|---|---|
| EnterorSpace | Flip (click trigger) |
| Tab | Focus flips it over (hover trigger) |
Accessibility
- Click mode is a toggle button with aria-pressed.
- The hidden face is aria-hidden, so only the visible side is read.
- Under reduced motion the faces cross-fade instead of rotating.
Motion
- A spring rotation (stiffness 140, damping 18) with backface hiding.
Responsive behavior
- Give it explicit dimensions; faces fill the card.
Performance
- One transformed element; both faces stay mounted.
Notes for AI
- Always set a height: faces are absolutely positioned.
- Use trigger="hover" only for decorative reveals.
This page as Markdown, for assistants and coding agents:
/components/flip-card/markdownThe full library index for assistants is at /llms.txt.
Lode222 doc pagesllms.txt