CreditCardInput
v1.0.1Updated 20 Jul 2026Credit card number field that auto-detects the brand from the typed prefix and shows a tinted badge (Visa, Mastercard, Amex, Discover, JCB). The mask switches itself to Amex's 15-digit `0000 000000 00000` grouping the moment a 34/37 prefix is seen, and back to 16-digit grouping otherwise. Sets inputMode="numeric" and autoComplete="cc-number"; the badge can be hidden with `hideBrand`.
Preview
Live · 5 stories▸Why this is recommendedformmaskinputcredit-card+6
CreditCardInput with brand.
- ✓Collecting card details in checkout
- ✓Adding a payment card on file in billing settings
- ✓Subscription payment method entry
- ✓Any card number field that should show the detected brand
- Brand auto-detect from the card prefix (Visa / MC / Amex / Discover / JCB)
- Mask adapts to Amex's 15-digit grouping automatically
- Tinted brand badge with a card icon; suppress via hideBrand
- inputMode="numeric" + autoComplete="cc-number" for autofill
- Works controlled or uncontrolled (keeps internal state when value is omitted)
- Exported `detectCardBrand(value)` helper for use outside the field
- ✕PCI-scoped card capture (use your gateway's hosted iframe such as Stripe Elements)
- ✕CVC or expiry entry (use InputMask or DateInput)
- ✕Free-form text (use Input)
Install
Ask your agent, or call the MCP tool directly. The resolved bundle is written into your project.
Usage
Tick variants in the left menu — each adds a tab with that variant’s real story source, the same code the preview above renders.
Props
valueCurrent masked card number; omit to run uncontrolled
—onAcceptFires whenever the masked value changes
—hideBrandHide the brand badge
—placeholderDefaults to '0000 0000 0000 0000'
—aria-invalidRenders the destructive border and ring
—disabledDisables the field; the value stays masked
—