About
Credit or debit card at ISO size, with embossed text and a flippable back. 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 Payment Card to your project and fits it to your theme.
Code
How Payment Card is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client"
import { useState } from "react"
import { PaymentCard, PaymentCardBack, PaymentCardBrand, PaymentCardChip, PaymentCardContactless, PaymentCardCvv, PaymentCardExpiry, PaymentCardFront, PaymentCardGlare, PaymentCardIssuer, PaymentCardMagstripe, PaymentCardName, PaymentCardNumber, PaymentCardSignature, PaymentCardTilt } from "@/components/ui/chanhdai-payment-card"
import { Button as ButtonPrimitive } from "@base-ui/react/button"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
// ---- inlined from src/components/ui/button.tsx ----
const buttonVariants = cva(
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/80",
outline:
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
ghost:
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
destructive:
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
link: "text-primary decoration-1 underline-offset-3 hover:underline active:scale-none",
eink: "border-foreground bg-background text-foreground hover:bg-muted aria-expanded:bg-muted dark:border-muted-foreground",
},
size: {
default:
"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
xs: "h-6 gap-1 rounded-[min(var(--radius-lg),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
sm: "h-8 gap-1 rounded-[min(var(--radius-lg),10px)] px-2.5 in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
icon: "size-9",
"icon-xs":
"size-6 rounded-[min(var(--radius-lg),8px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
"icon-sm":
"size-8 rounded-[min(var(--radius-lg),10px)] in-data-[slot=button-group]:rounded-lg",
"icon-lg": "size-10",
},
},
// Compound classes come after size classes, so this wins over their radius
compoundVariants: [{ variant: "eink", className: "rounded-none" }],
defaultVariants: {
variant: "default",
size: "default",
},
}
)
function Button({
className,
variant = "default",
size = "default",
...props
}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
return (
<ButtonPrimitive
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
}
export { Button, buttonVariants }
// ---- 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>`
}
export default function PaymentCardDemo() {
const [flipped, setFlipped] = useState(false)
return (
<div className="flex flex-col items-center gap-6">
<PaymentCardTilt>
<PaymentCard flipped={flipped}>
<PaymentCardFront className="bg-primary text-primary-foreground">
<PaymentCardIssuer>
<ChanhDaiMark />
</PaymentCardIssuer>
<PaymentCardChip />
<PaymentCardContactless />
<PaymentCardNumber value="4242 4242 4242 4242" />
<PaymentCardExpiry>12/30</PaymentCardExpiry>
<PaymentCardName>NGUYEN CHANH DAI</PaymentCardName>
<PaymentCardBrand brand="visa" />
<PaymentCardGlare />
</PaymentCardFront>
<PaymentCardBack className="bg-primary text-primary-foreground">
<PaymentCardMagstripe />
<PaymentCardSignature />
<PaymentCardCvv>123</PaymentCardCvv>
<PaymentCardBrand brand="visa" />
<PaymentCardGlare />
</PaymentCardBack>
</PaymentCard>
</PaymentCardTilt>
<Button variant="outline" onClick={() => setFlipped(!flipped)}>
{flipped ? "Show front" : "Show back"}
</Button>
</div>
)
}







