About
Folded card that opens like the iPhone Duo, blurring as the cover turns. From chanhdai.com (ncdai), MIT.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Foldable to your project and fits it to your theme.
Code
How Foldable is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import { Fragment, type ReactNode } from "react"
import { Foldable, FoldableCover, FoldableInsideLeft, FoldableInsideRight, FoldableSlider, FoldableStage } from "@/components/ui/chanhdai-foldable"
// ---- inlined from src/components/chanhdai-mark.tsx ----
export function ChanhDaiMark(props: React.ComponentProps<"svg">) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 512 256"
aria-hidden
{...props}
>
<path
fill="currentColor"
d="M192 256H64v-64h128v64ZM448 64H320v128h128v64H256V0h192v64ZM64 192H0V64h64v128ZM512 192h-64V64h64v128ZM192 64H64V0h128v64Z"
/>
</svg>
)
}
export function getMarkSVG() {
return `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 256 128"><path fill="currentColor" d="M96 128H32V96h64v32ZM224 32h-64v64h64v32h-96V0h96v32ZM32 96H0V32h32v64ZM256 96h-32V32h32v64ZM96 32H32V0h64v32Z"/></svg>`
}
const PROFILE = {
username: "ncdai",
displayName: "Chánh Đại",
jobTitle: "Design Engineer",
bio: "Creating with code. Small details matter.",
pronouns: "he/him",
avatar: "https://cdn.21st.dev/assets/mirror/41/4155327cd7a8c22a0c625153237b75435899275c5a5581bb02cc6dbb4d28cb1d.webp",
}
const CONTACTS = [
{ label: "Web", value: "chanhdai.com" },
{ label: "GitHub", value: "ncdai" },
{ label: "X", value: "@iamncdai" },
{ label: "LinkedIn", value: "ncdai" },
]
export default function FoldableDemo() {
return (
<Foldable className="[--foldable-radius:--spacing(3)] [--foldable-surface:var(--card)] [--foldable-w:min(16rem,calc(50vw-2rem))]">
<FoldableStage>
<FoldableInsideRight>
<CardFrame>
<ContactList />
</CardFrame>
</FoldableInsideRight>
<FoldableCover>
<CardFrame />
</FoldableCover>
<FoldableInsideLeft>
<CardInside />
</FoldableInsideLeft>
</FoldableStage>
<FoldableSlider />
</Foldable>
)
}
/**
* Shared by the cover and the page beneath it, so what the lifting cover
* uncovers lines up with what it just showed.
*/
function CardFrame({ children }: { children?: ReactNode }) {
return (
<div className="flex size-full flex-col p-5">
<div className="flex items-start justify-between">
<ChanhDaiMark className="h-5 w-10" />
<span className="font-mono text-xs text-muted-foreground">
@{PROFILE.username}
</span>
</div>
<div className="flex flex-1 flex-col justify-center">{children}</div>
<div>
<p className="text-xl font-medium tracking-tight">
{PROFILE.displayName}
</p>
<p className="text-sm text-muted-foreground">{PROFILE.jobTitle}</p>
</div>
</div>
)
}
function ContactList() {
return (
<dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 font-mono text-xs">
{CONTACTS.map(({ label, value }) => (
<Fragment key={label}>
<dt className="text-muted-foreground">{label}</dt>
<dd className="truncate text-right">{value}</dd>
</Fragment>
))}
</dl>
)
}
function CardInside() {
return (
<div className="flex size-full flex-col justify-between p-5">
<img
className="size-16 rounded-full border object-cover"
src={PROFILE.avatar}
alt=""
draggable={false}
/>
<div className="flex flex-col gap-2">
<p className="text-lg/snug font-medium tracking-tight text-balance">
{PROFILE.bio}
</p>
<p className="font-mono text-xs text-muted-foreground">
{PROFILE.pronouns}
</p>
</div>
</div>
)
}







