← Back to Table of Contents
Summary
Payment input that combines four fields (number, name, expiry, CVV) into one cohesive component. Includes an interactive 3D-style card preview that flips when focusing the CVV field and validates numbers using the Luhn algorithm.
Basic usage
Custom labels and variant
State & validation
The four input values are strings: number, name, expiry, and cvv.
Numbers are grouped while typing and expiry uses MM/YY. Validation runs on the
server when the form is submitted; changing HTML or JavaScript cannot bypass it.
With the default never_store_pan policy, a nonempty card number requires a
registered tokenizer. A successful submission saves this shape:
CVV is excluded from the saved value in every configuration. A tokenizer returning
no token or throwing an exception produces a validation error. Its result is reused
between validation and saving within one field instance, avoiding a second provider
call for the same number.
This component collects new card details. Use a separate selection field for saved
payment tokens; a token is not a card number and must not be supplied as editable
card input. The default policy does not authorize saving raw card numbers.
Built-in Validation
CreditCardField performs several automatic checks:
- Luhn Check: Validates the card number checksum.
- Expiry Date: Ensures the card is not expired and the format is
MM/YY.
- CVV Format: Validates 3 or 4 digit numeric codes.
- Required Fields: If
required(), all four sub-fields must be filled, including when the whole value is empty.
- Payload checks: Unknown keys, nested values, control characters, oversized values and letters in numeric fields are rejected. Card numbers are limited to 13–19 digits and names to 200 characters.
Validation checks the submitted data before any display truncation. The display
formatter does not silently repair a malformed submission.
Visual Customization
Variants
Choose from four built-in card themes:
Change the style of the text inputs below the card:
primary: Standard bordered inputs.
secondary: Subtle background-only inputs.
flat: Transparent input surface.
Configuration API
All methods accept Closure unless noted.
Real-world examples
Branded card collection
Register the tokenizer shown below before submitting nonempty card details under
the default storage policy.
Playground
/admin/flex-fields/credit-card
See Playground for setup.
CreditCardField integrates with Media Ingress for its configurable card-storage policy.
Host wiring:
CVV is never included in the dehydrated value. Raw card input passes through
the application’s Livewire form state. This field does not provide a hosted payment
iframe, encryption, payment authorization or PCI certification. Do not treat the
storage policy as a guarantee about application logs, sessions or provider handling.
Shared controls and responsive behavior
All four controls use the same Blade input and shell as Flex Text Input.
Their size, rounding, input variant, dark theme and focus outline come from that
shared component. Its stylesheet is declared as a shared dependency and loaded
once; the standalone text-input JavaScript is not required for these controls.
The card preview scales to its parent column, retains its four themes, supports
right-to-left form layout and respects reduced-motion preferences. Numeric inputs
keep left-to-right digit order. Formatting preserves the caret while editing a
number, and deleting beside a separator removes a digit rather than trapping the
cursor. The preview updates locally without timers, animation-frame loops or
geometry observers.
CSS classes (reference)
Last modified on October 16, 2026