Cards
RevealPanel
A panel slides up from the bottom of the card on hover or keyboard focus, and the main content steps back. Give the card a fixed height.
Download
- React
- Tailwind CSS v4
components/ui/reveal-panel.tsx
import type { ReactNode } from "react";
type RevealPanelProps = {
/** What always shows. */
children: ReactNode;
/** What slides up on hover or keyboard focus. */
reveal: ReactNode;
className?: string;
/** Look of the panel that slides up. */
panelClassName?: string;
};
/* RevealPanel: a panel slides up from the bottom of the card on hover or focus. CSS only. */
export function RevealPanel({
children,
reveal,
className = "rounded-2xl border border-white/10 bg-[#16132a] p-6 text-white",
panelClassName = "bg-[#a78bfa] p-6 text-[#0b0a14]",
}: RevealPanelProps) {
return (
<div tabIndex={0} className={`group relative overflow-hidden outline-none focus-visible:ring-2 focus-visible:ring-[#a78bfa] ${className}`}>
<div className="transition-[opacity,transform] duration-500 ease-[cubic-bezier(.2,.8,.2,1)] group-hover:-translate-y-3 group-hover:opacity-40 group-focus-within:-translate-y-3 group-focus-within:opacity-40 motion-reduce:transition-none">
{children}
</div>
<div
className={`absolute inset-x-0 bottom-0 translate-y-full transition-transform duration-500 ease-[cubic-bezier(.2,.8,.2,1)] group-hover:translate-y-0 group-focus-within:translate-y-0 motion-reduce:transition-none ${panelClassName}`}
>
{reveal}
</div>
</div>
);
}
1. Paste the Code tab into
components/ui/reveal-panel.tsx. The styles are Tailwind CSS v4 classes.2. Use it. This is the preview above:
app/reveal-panel-demo.tsx
import { RevealPanel } from "@/components/ui/reveal-panel"; export default function RevealPanelExample() { return ( <div className="grid h-full place-items-center bg-[#0b0a14] p-6"> <RevealPanel className="h-[200px] w-full max-w-[300px] rounded-2xl border border-white/10 bg-[#16132a] p-6 text-white" reveal={ <> <p className="text-sm font-semibold">3 bedrooms · 2 baths</p> <p className="mt-1 text-sm">Lift, covered parking, 5 min to the metro.</p> </> } > <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-[#a78bfa]">Anna Nagar</p> <p className="mt-3 text-2xl font-semibold">₹32,000 / month</p> <p className="mt-2 text-sm text-white/60">Hover or Tab to see details.</p> </RevealPanel> </div> ); }
Props
| Name | Type | Default | What it does |
|---|---|---|---|
| children | ReactNode | — | What always shows. |
| reveal | ReactNode | — | What slides up. |
| panelClassName | string | violet panel | Look of the panel. |
| className | string | dark violet card | Replaces the default look. |