Skip to Content
Kokonut UI

IN-12InputsNew, October 22, 2026

Card Field

A one-row card input for checkout. The number groups the way the brand prints it, then slides to its last four to make room for expiry and CVC.

Install with
lucide-react, motion

PRONeed the button that charges it? Pay Button is in Kokonut UI Pro

Installation

Card Field is a free, open-source React component in the Kokonut UI Inputs collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/card-field.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/card-field

Or add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/card-field.tsx.

npm install lucide-react motion

Usage

import CardField from "@/components/kokonutui/card-field";

export default function Example() {
  return <CardField />;
}

Props

amount
numberDefault 48

What the button charges.

currency
stringDefault "$"
onPay
(card: CardDetails) => Promise<void> | void

Charge the card. Return a promise and the button waits for it.

testMode
booleanDefault true

Shows a "Use test card" link that types 4242… in for you.

className
string

Extra classes for the root element.

CardDetails

brandrequired
Brand
last4required
string
expiryrequired
string

MM/YY

Brand

type Brand = "visa" | "mastercard" | "amex" | "discover" | "unknown";

Dependencies

NeedsVersionComes from
lucide-react^0.556.0npm, installed by the CLI
motion^12.23.25npm, installed by the CLI
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.