<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>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.
| Protection | Detail |
|---|---|
| PAN never exposed | Full card number absent from events, hidden inputs, and audit logs — only last4 is shared |
| CVC never exposed | CVC absent from events and hidden inputs; masked with type="password" in the DOM |
| Luhn validation | Client-side Luhn check on every keystroke — invalid PANs are rejected before submission |
| Card type detection | Visa, Mastercard, Amex, Discover, Diners, JCB — expiry and CVC length rules adjust per network |
| PAN masking on blur | Card number masked to •••• •••• •••• 1234 when the user leaves the field |
| No autocomplete | All fields set autocomplete="off" — browser autofill is disabled for card data |
| Rate limiting | 5 attempts per minute — brute-force card guessing throttled client-side |
| Full audit logging | All interactions recorded via getAuditLog() without capturing raw PAN or CVC |
| Memory wiped on detach | All sensitive state cleared in disconnectedCallback() |
Theming
Override CSS custom properties at :root, per-component, or per-instance.
| Variable | Default | Description |
|---|---|---|
| --secure-card-width | 340px | Width of the 3D card preview |
| --secure-card-radius | 16px | Border radius of the card preview |
| --secure-card-font | 'Courier New', monospace | Font for card number digits |
| --secure-card-gradient | linear-gradient(135deg, #1e2a4a, #2d4a8a) | Card face background (overridden per card type) |
| --secure-card-transition | transform 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>
}