# Card flip form

A card form where the card changes material and turns over for the code.

Also called: credit card form, payment form, card input.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: A card that knows its network. From the first digit the card wipes into its network's material with a sheen, digits stamp in, and focusing the code turns it over. Preview: https://chatcn.dev/preview/card-flip-form-demo

From the first digit the blank frosted card knows its network and changes material in a diagonal wipe with a specular sheen riding the edge: brushed graphite, green or terracotta, for invented networks with no real marks. Each digit stamps into the plastic as you type. Focusing the security code turns the card over to a ringed code box on the back, and the pay button wakes once every field is complete.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/card-flip-form
```

## Usage

```tsx
import { CardFlipForm } from "@/components/ui/chatcn/pro/card-flip-form"

<CardFlipForm submitLabel="Pay $20.00" onSubmit={(card) => tokenize(card)} />
```

The networks are placeholders keyed by the first digit; map them to your own finishes. Never send raw card numbers to your server: hand them to your payment provider's tokenizer.

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `value` / `onValueChange` | `{ number, expiry, cvc }` | Optional control |
| `field` / `onFieldChange` | `"number" | "expiry" | "cvc" | null` | Drives the card without moving focus |
| `submitLabel` | `ReactNode` |  |
| `onSubmit` | `(value) => void` | Only when complete |
| `issuer` | `string` | Printed on the card |

## Accessibility

- Real inputs with card autocomplete and labels; the card is decoration and hidden from assistive tech.

## Motion

- The wipe takes 760 ms, the flip 820 ms with a small overshoot. Reduced motion: the finish and side swap at once.

Source: https://chatcn.dev/docs/components/card-flip-form