Documentation
Cardfield — Payment Form UI
Version 1.0.0 · Vanilla HTML · 12 files · 76 KB
Getting started
- Unzip the download and open index.html in a browser. No server, installation or build step is needed.
- Edit the text directly in the HTML files.
- Change colours, fonts and spacing through the CSS custom properties at the top of assets/css/style.css.
- Replace the artwork in assets/images/ with your own images.
- Upload the whole folder to any static host.
File structure
The download contains these 12 files:
- LICENSE.txt1.7 KB
- README.md2.5 KB
- assets/css/style.css13 KB
- assets/fonts/space-grotesk-LICENSE.txt4.3 KB
- assets/fonts/space-grotesk-latin-wght-normal.woff222 KB
- assets/fonts/space-mono-LICENSE.txt4.6 KB
- assets/fonts/space-mono-latin-400-normal.woff216 KB
- assets/fonts/space-mono-latin-700-normal.woff216 KB
- assets/images/favicon.svg493 B
- assets/js/main.js9.9 KB
- documentation/index.html11 KB
- index.html8.3 KB
Colours
These custom properties are defined at the top of the stylesheet. Change a value once and it updates everywhere it is used.
--c-bg#0f172a--c-bg-2#131c33--c-panel#1a2540--c-line#2b3a5c--c-ink#f1f5f9--c-muted#a9b6cc--c-violet#7c3aed--c-blue#2563eb--c-accent#a78bfa--c-ok#34d399--c-error#fda4af--c-error-bg#3a1424
Interactive features
Card preview and flip
The preview is updated from the input handlers in assets/js/main.js. The flip is the .is-flipped class on .flip, toggled when the security-code field gains or loses focus.
Card types and validation
Edit the TYPES array at the top of main.js to change prefixes, grouping gaps, length and code length. checkNumber() runs the Luhn test.
Processing and success
PROCESSING_MS and AMOUNT_LABEL in main.js control the simulated delay and amount. Replace the setTimeout in the submit handler with a call to your payment provider's client library.
Customisation notes
Change the card gradient
The card background is the --card-grad token in the :root block of style.css; the pay button uses the same token.
Update the order summary
The order lines are a definition list in index.html. Change the amounts there and the AMOUNT_LABEL constant in main.js.
Going live
Never send raw card data to your own server. Replace the form fields with your payment provider's hosted fields and keep this layout and the preview for presentation.
What is front-end only
This is a front-end template. The behaviours below are demonstrations that run in the browser; connect them to your own server or service before relying on them.
- No payment is processed: validation and the success receipt run in the browser only, card data is never sent or stored, and the reference number is random.
- Test card numbers are for demonstration and only satisfy the Luhn check.
Bundled components and licences
Everything the template needs is inside the download; nothing is loaded from the network.
- Space Grotesk typeface — OFL-1.1 (
assets/fonts/space-grotesk-LICENSE.txt) - Space Mono typeface — OFL-1.1 (
assets/fonts/space-mono-LICENSE.txt)
Changelog
Version 1.0.0 · Nov 23, 2026
- Initial release.