Card Field - React Component | Kokonut UI
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
npx shadcn@latest add https://kokonutui.com/r/card-field.json
or follow the usage instructions to add the card-field component from Kokonut UI to this project.
Usage Example
import CardField from "@/components/kokonutui/card-field";
export default function Example() {
return <CardField />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
amount |
number |
48 |
What the button charges |
currency |
string |
"$" |
Currency symbol |
onPay |
`(card: CardDetails) => Promise |
void` | Charge the card. Return a promise and the button waits for it. |
testMode |
boolean |
true |
Shows a "Use test card" link that types 4242… in for you. |
className |
string |
Extra classes for the root element |
CardDetails
| Field | Type | Required | Description |
|---|---|---|---|
brand |
string |
required | The brand of the card |
last4 |
string |
required | Last four digits of the card |
expiry |
string |
required | Expiry date in MM/YY format |
Brand Type
type Brand = "visa" | "mastercard" | "amex" | "discover" | "unknown";
Dependencies
| Needs | Version | Comes from |
|---|---|---|
lucide-react |
^0.556.0 |
npm, installed by the CLI |
motion |
^12.23.25 |
npm, installed by the CLI |
cn from lib/utils.ts |
shadcn init | |
React |
19 |
Your app |
Tailwind CSS |
4 |
Your app |
No provider, font, or global CSS to set up: the file works as soon as it lands.