Mohammad Shehadeh

Credit Card Input

Cards 1

About

Card number, expiry, and CVC in one row with brand detection, per-brand grouping, Luhn and expiry validation, and auto-advance between fields.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Credit Card Input to your project and fits it to your theme.

Code

How Credit Card Input is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";
import {
  CreditCardInput,
  CreditCardInputNumber,
  CreditCardInputExpiry,
  CreditCardInputCvc,
  type CreditCardChange,
} from "@/components/ui/credit-card-input";

export default function CreditCardInputDemo() {
  const [card, setCard] = React.useState<CreditCardChange | null>(null);

  return (
    <div className="grid w-full max-w-md gap-2">
      <label className="text-sm font-medium text-foreground">
        Card details
      </label>
      <CreditCardInput onValueChange={setCard}>
        <CreditCardInputNumber />
        <CreditCardInputExpiry />
        <CreditCardInputCvc />
      </CreditCardInput>
      <p className="text-xs text-muted-foreground tabular-nums">
        Try 4242 4242 4242 4242
      </p>
      {card?.valid && <p className="text-xs text-success">Card looks valid.</p>}
    </div>
  );
}

Dependencies

More by Mohammad Shehadeh

View all
  • Ecommerce Category Page

    Ecommerce Category Page

    99
  • Feature Problem Cards

    Feature Problem Cards

    99
  • Split Login

    Split Login

    93
  • Feature Grid Spotlight Cards

    Feature Grid Spotlight Cards

    90
  • Comparison Section

    Comparison Section

    81
  • Rounded Top Footer

    Rounded Top Footer

    79
  • Comparison Table

    Comparison Table

    77
  • FAQ Two Column

    FAQ Two Column

    76

More in Cards

View all
  • Course Design Cards

    Course Design Cards

    1.3K
  • Statistics Card 7

    Statistics Card 7

    327
  • Statistics Card 2

    Statistics Card 2

    305
  • Interactive Tech Stack Bento Grid with Hover Effects

    Interactive Tech Stack Bento Grid with Hover Effects

    621
  • Card Studio

    Card Studio

    5
  • The Item one

    The Item one

    4
  • Card

    Card

    9
  • Weather Card

    Weather Card

    65