credit-card
kibo-ui-registry/credit-cardFreeComponent
Credit card components for displaying and validating credit card information.
Live preview
live · rendered by the registry
Rendered by Kibo UI Registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.kibo-ui.com/r/credit-card.jsonSource
1"use client";23import {4 type ComponentProps,5 createContext,6 type HTMLAttributes,7 type ReactNode,8 useContext,9 useEffect,10 useState,11} from "react";12import { PaymentIcon } from "react-svg-credit-card-payment-icons";13import { cn } from "@/lib/utils";1415const useSupportsHover = () => {16 const [supportsHover, setSupportsHover] = useState(false);1718 useEffect(() => {19 const mql = window.matchMedia("(hover: hover)");20 const handler = (e: MediaQueryListEvent) => setSupportsHover(e.matches);2122 setSupportsHover(mql.matches);23 mql.addEventListener("change", handler);2425 return () => mql.removeEventListener("change", handler);26 }, []);2728 return supportsHover;29};3031export type CreditCardProps = HTMLAttributes<HTMLDivElement>;3233export const CreditCard = ({ className, ...props }: CreditCardProps) => (34 <div35 className={cn(36 "group/kibo-credit-card perspective-distant aspect-[8560/5398] w-full max-w-96 text-white",37 "@container",38 className39 )}40 {...props}41 />42);4344const CreditCardFlipContext = createContext(false);4546export type CreditCardFlipperProps = HTMLAttributes<HTMLDivElement>;4748export const CreditCardFlipper = ({49 className,50 children,51 ...props52}: CreditCardFlipperProps & { children?: ReactNode }) => {53 const supportsHover = useSupportsHover();54 const [isFlipped, setIsFlipped] = useState(false);5556 const handleClick = () => {57 if (!supportsHover) {58 setIsFlipped((prev) => !prev);59 }60 };6162 return (63 <CreditCardFlipContext.Provider value={true}>64 {/* biome-ignore lint/nursery/noStaticElementInteractions: tap to flip for touch devices */}65 <div66 aria-label="Flip credit card"67 className={cn(68 "h-full w-full",69 "@xs:rounded-2xl rounded-lg",70 "transform-3d transition duration-700 ease-in-out",71 supportsHover &&72 "group-hover/kibo-credit-card:-rotate-y-180 group-hover/kibo-credit-card:shadow-lg",73 !supportsHover && isFlipped && "-rotate-y-180 shadow-lg",74 className75 )}76 onClick={handleClick}77 {...props}78 >79 {children}80 </div>81 </CreditCardFlipContext.Provider>82 );83};8485export type CreditCardNameProps = HTMLAttributes<HTMLParagraphElement>;8687export const CreditCardName = ({88 className,89 style,90 ...props91}: CreditCardNameProps) => (92 <p93 className={cn("font-semibold uppercase", className)}94 style={{95 lineHeight: "100%",96 ...style,97 }}98// … truncated
What it pulls in
npm packages
Files it writes
More from Kibo UI Registry
All 41 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| announcementannouncement | Kibo UI Registry | Components | Free | no deps | |
| avatar-stackavatar-stack | Kibo UI Registry | Components | Free | no deps | |
| bannerbanner | Kibo UI Registry | Components | Free | 2 deps | |
| calendarcalendar | Kibo UI Registry | Components | Free | 3 deps | |
| choiceboxchoicebox | Kibo UI Registry | Components | Free | 2 deps | |
| code-blockcode-block | Kibo UI Registry | Components | Free | 5 deps · 2 files | |
| color-pickercolor-picker | Kibo UI Registry | Components | Free | 3 deps | |
| comboboxcombobox | Kibo UI Registry | Components | Free | 2 deps |
