Import Card Field and compose its parts.
card-field.tsx
CardField
<fieldset>| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false | |
| value | CardValue | — | The three parts as shown (controlled). Raw digits are formatted: "0829" shows "08/29". |
| default | Partial<CardValue> | — | The three parts at first (uncontrolled). |
| on | — | Runs on every change with the shown parts and the details (brand, raw parts, problems). | |
| now | DisplayNow | — | "Now" for the expiry check (tests, stories). Default: the time the field mounts. |
| labels | — | The words (CARD_LABELS): the accessible names of the three inputs and the error texts, to translate them. {length} in cvcIncomplete is the code length of the brand. | |
| placeholders | Partial<Record<CardPart, string>> | — | |
| read | boolean | false | |
| show | boolean | false | Show the problems of every part now, as after a submit (a declined payment, a server check). |
| ...props | <fieldset> attributes | — | Every other attribute goes to the <fieldset>, with a ref. |
CardFieldLabel
<label>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <label> attributes | — | Every other attribute goes to the <label>, with a ref. |
CardFieldGroup
<div>CardFieldBrand
<div>CardFieldNumber
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| guide | boolean | — | The ghost guide of the slots still to fill, while the input has focus. Default true. |
| raw | string | — | Also submit the raw value under this name (a hidden input), next to the shown one. |
| reject | boolean | — | Nudge the field 2px when the mask rejects a key. Default true. |
| on | — | Runs when the mask rejects a key (a letter in a number, a 13th month). | |
| ref | Ref<HTMLInputElement> | — | |
| rounded | "default""full" | — | |
| size | "default""lg""sm""xs" | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
CardFieldExpiry
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| guide | boolean | — | The ghost guide of the slots still to fill, while the input has focus. Default true. |
| raw | string | — | Also submit the raw value under this name (a hidden input), next to the shown one. |
| reject | boolean | — | Nudge the field 2px when the mask rejects a key. Default true. |
| on | — | Runs when the mask rejects a key (a letter in a number, a 13th month). | |
| ref | Ref<HTMLInputElement> | — | |
| rounded | "default""full" | — | |
| size | "default""lg""sm""xs" | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
CardFieldCvc
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| guide | boolean | — | The ghost guide of the slots still to fill, while the input has focus. Default true. |
| raw | string | — | Also submit the raw value under this name (a hidden input), next to the shown one. |
| reject | boolean | — | Nudge the field 2px when the mask rejects a key. Default true. |
| on | — | Runs when the mask rejects a key (a letter in a number, a 13th month). | |
| ref | Ref<HTMLInputElement> | — | |
| rounded | "default""full" | — | |
| size | "default""lg""sm""xs" | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
CardFieldError
<p>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <p> attributes | — | Every other attribute goes to the <p>, with a ref. |
| Tab | Moves between the number, the expiry, and the code. |
|---|---|
| Backspace | In an empty expiry or code, moves to the end of the part before it. |
Built with
Installs with Card Field
- Components
- Card Brand,Input Group,Masked Input













