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#
| Prop | Type | Default |
|---|---|---|
onChange | (value: CreditCardValue) => void | - |
defaultValue | Partial<Pick<CreditCardValue, "number" | "expiry" | "cvc" | "name" | "postalCode">> | {} |
showName | boolean | true |
showPostalCode | boolean | true |
showBrands | boolean | true |
label | string | "Card details" |
hint | React.ReactNode | "Test with 4242 4242 4242 4242 and an... |
disabled | boolean | false |
className | string | - |
Dependencies#
npm
lucide-reactmotion
Built from
Related billing components#
Add Card FormCompact payment form for card number, expiry and CVC with correct autocomplete hints, numeric input mode and a full width save button. Ready for your processor.Billing AddressTailwind billing address fieldset with a multiline street field and a responsive row for city, state and postal code. Drops into checkout forms.Cancel FlowTwo step subscription cancellation flow: ask for a reason with radio options, then confirm with a destructive button or go back. Tells users what they keep.Comparison TablePlan comparison table with features as rows and plans as columns, showing check or dash icons for booleans and text for values. Scrolls on mobile.Credit BalanceCompact credit balance pill with a small label and a large tabular figure. Shows remaining credits or usage balance for AI and pay-as-you-go apps.Downgrade WarningTailwind plan downgrade warning card with an amber border, a summary of what gets locked on the free plan, and Keep plan or Downgrade buttons.
All pricing and billing components