Credit Card Input

React credit card input that groups the number by brand, runs a Luhn check, formats expiry as MM / YY and sizes the CVC for Amex. A UI only form, no payment processing.

src/registry/ui/credit-card-input.tsx/r/credit-card-input.json

Installation#

bash
npx shadcn@latest add https://ui.minidev.pro/r/credit-card-input.json

Usage#

tsx
import { CreditCardInput } from "@/components/ui/credit-card-input"

export function Example() {
  return <CreditCardInput />
}

API reference#

CreditCardInput props
PropTypeDefault
onChange(value: CreditCardValue) => void-
defaultValuePartial<Pick<CreditCardValue, "number" | "expiry" | "cvc" | "name" | "postalCode">>{}
showNamebooleantrue
showPostalCodebooleantrue
showBrandsbooleantrue
labelstring"Card details"
hintReact.ReactNode"Test with 4242 4242 4242 4242 and an...
disabledbooleanfalse
classNamestring-

Dependencies#

npm

lucide-reactmotion

Built from

All pricing and billing components