<secure-card>

A payment card input with a live 3D card preview, automatic card type detection, Luhn validation, and full PAN masking. Security tier is locked to CRITICAL — the full card number and CVC are never exposed in events, form submissions, or audit logs.

<script type="module"
  src="/components/secure-card/secure-card.js">
</script>
View API Reference →
Live Demo

Configurations

Default (card + expiry + CVC)
<secure-card
  name="payment">
</secure-card>
show-name (cardholder name field)
<secure-card
  name="payment"
  show-name>
</secure-card>
required
<secure-card
  name="payment"
  required>
</secure-card>
label
<secure-card
  name="payment"
  label="Billing Card">
</secure-card>
disabled
<secure-card
  name="payment"
  disabled>
</secure-card>
Inside secure-form
<secure-form
  action="/checkout"
  method="POST"
  security-tier="critical">
  <secure-card
    name="payment"
    label="Card Details"
    required>
  </secure-card>
  <button type="submit">Pay Now</button>
</secure-form>

Security Features

Security tier is fixed at CRITICAL and cannot be changed. All protections below are always active.

ProtectionDetail
PAN never exposedFull card number absent from events, hidden inputs, and audit logs — only last4 is shared
CVC never exposedCVC absent from events and hidden inputs; masked with type="password" in the DOM
Luhn validationClient-side Luhn check on every keystroke — invalid PANs are rejected before submission
Card type detectionVisa, Mastercard, Amex, Discover, Diners, JCB — expiry and CVC length rules adjust per network
PAN masking on blurCard number masked to •••• •••• •••• 1234 when the user leaves the field
No autocompleteAll fields set autocomplete="off" — browser autofill is disabled for card data
Rate limiting5 attempts per minute — brute-force card guessing throttled client-side
Full audit loggingAll interactions recorded via getAuditLog() without capturing raw PAN or CVC
Memory wiped on detachAll sensitive state cleared in disconnectedCallback()

Theming

Override CSS custom properties at :root, per-component, or per-instance.

VariableDefaultDescription
--secure-card-width340pxWidth of the 3D card preview
--secure-card-radius16pxBorder radius of the card preview
--secure-card-font'Courier New', monospaceFont for card number digits
--secure-card-gradientlinear-gradient(135deg, #1e2a4a, #2d4a8a)Card face background (overridden per card type)
--secure-card-transitiontransform 0.6s cubic-bezier(0.4, 0, 0.2, 1)3D flip animation timing

Framework Examples

Web Components work natively in all frameworks. No wrappers, no adapters.

Plain HTML html
<script type="module"
  src="/components/secure-card/secure-card.js">
</script>
<script type="module"
  src="/components/secure-form/secure-form.js">
</script>

<secure-form action="/checkout" method="POST"
  security-tier="critical">
  <secure-card
    name="payment"
    label="Payment Details"
    show-name
    required>
  </secure-card>
  <button type="submit">Pay Now</button>
</secure-form>
React (JSX) tsx
import { useEffect, useRef } from 'react';

export function CheckoutForm() {
  const cardRef = useRef(null);

  useEffect(() => {
    import('/components/secure-card/secure-card.js');
    import('/components/secure-form/secure-form.js');

    const el = cardRef.current;
    el?.addEventListener('secure-card-change', (e) => {
      console.log('card type:', e.detail.cardType);
      console.log('last4:', e.detail.last4);
      // full PAN never in detail
    });
  }, []);

  return (
    <secure-form action="/checkout" method="POST"
      security-tier="critical">
      <secure-card ref={cardRef}
        name="payment" show-name required />
      <button type="submit">Pay Now</button>
    </secure-form>
  );
}
Go / Templ templ
templ CheckoutForm(action string) {
  <secure-form
    action={ action }
    method="POST"
    security-tier="critical">
    <secure-card
      name="payment"
      label="Payment Details"
      show-name
      required>
    </secure-card>
    <button type="submit">Pay Now</button>
  </secure-form>
}