Credit Card
loomui/credit-cardFreeComponent
A placeholder payment card with a contact plate, a number and an aurora drifting under the face.
Live preview
live · rendered by the registry
Rendered by loomui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://loomui.design/r/credit-card.jsonSource
1"use client"23import * as React from "react"45import { cn } from "@/lib/utils"6import { useInViewport } from "@/registry/lib/use-in-viewport"78export interface CreditCardProps extends React.ComponentProps<"div"> {9 /** Which face to draw. Pair the two inside a flip card to turn it over. */10 side?: "front" | "back"11 /** Number across the face. Grouped however you write it. */12 number?: string13 /** Name along the bottom. */14 holder?: string15 /** Expiry along the bottom. */16 expiry?: string17 /** Security code on the back. */18 cvv?: string19 /** Name in the top left. */20 issuer?: React.ReactNode21 /** Mark in the bottom right. Leave it out for the placeholder rings. */22 brand?: React.ReactNode23 /** Show only the last four digits. */24 masked?: boolean25 /** Colours of the aurora drifting under the face. One blob per colour. */26 colors?: string[]27 /** Seconds for one drift of a single blob. */28 duration?: number29 /** Render the face still, with no drift. */30 disabled?: boolean31}3233const DEFAULT_COLORS = ["#22d3ee", "#6366f1", "#c084fc", "#14b8a6"]3435/**36 * Fixed rather than random. A card is one frame, and four blobs placed by hand37 * cover it better than four that happen to land in the same corner.38 */39const BLOB_LAYOUT = [40 { size: 78, x: 12, y: 18, speed: 1, delay: 0 },41 { size: 66, x: 82, y: 26, speed: 1.35, delay: -6 },42 { size: 88, x: 68, y: 88, speed: 0.85, delay: -11 },43 { size: 58, x: 34, y: 76, speed: 1.6, delay: -3 },44]4546/** Keeps the last four and turns the rest into bullets, groups intact. */47function maskNumber(number: string) {48 const digits = number.replace(/\D/g, "")49 const hidden = Math.max(digits.length - 4, 0)50 let seen = 05152 return number.replace(/\d/g, (digit) => {53 seen += 154 return seen <= hidden ? "•" : digit55 })56}5758/** The contact plate. Drawn rather than shipped as an image so it stays sharp. */59function Chip() {60 return (61 <svg62 viewBox="0 0 40 30"63 aria-hidden="true"64 className="h-6 w-8 drop-shadow-sm sm:h-8 sm:w-11"65 >66 <rect67 width="40"68 height="30"69 rx="5"70 fill="url(#loom-card-chip)"71 stroke="rgba(0,0,0,0.18)"72 />73 <g stroke="rgba(0,0,0,0.28)" strokeWidth="1" fill="none">74 <path d="M14 0v30M26 0v30M0 11h14M26 11h14M0 19h14M26 19h14" />75 </g>76 <defs>77 <linearGradient id="loom-card-chip" x1="0" y1="0" x2="1" y2="1">78 <stop offset="0%" stopColor="#f6e7bd" />79// … truncated
What it pulls in
Other registry items
Files it writes
More from loomui
All 91 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aurora Backdropaurora-backdrop | loomui | Components | Free | no deps | |
| Bento Gridbento-grid | loomui | Components | Free | no deps | |
| Card Stackcard-stack | loomui | Components | Free | no deps | |
| Compare Slidercompare-slider | loomui | Components | Free | no deps | |
| Confetti Buttonconfetti-button | loomui | Components | Free | no deps | |
| Count Upcount-up | loomui | Components | Free | no deps | |
| Drawerdrawer | loomui | Components | Free | 1 dep | |
| Elastic Tabselastic-tabs | loomui | Components | Free | no deps |
