Skip to content

One-Page Checkout with Payment Options

Tailwind CSS one-page checkout with shipping address, shipping method cards, card / wallet / bank payment tabs, discount code and a live order summary.

Also known as: checkout page, payment form, checkout form with order summary, ecommerce checkout

One-Page Checkout with Payment Options live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A one-page checkout built with Tailwind CSS and vanilla JavaScript. Shipping address, shipping method and payment sit in three numbered sections, next to a sticky order summary with product photos, a discount code field and a live total. Use it in an online store or booking flow.

How it works

The root is section.opc-checkout, and the whole page is a single form with data-opc-form. On large screens a lg:grid-cols-[1fr_22rem] grid puts the sections on the left and the summary aside on the right; on phones the summary follows the form, so "Place order" stays at the end. The desktop layout is compact: the address uses a lg:grid-cols-12 grid with two rows of fields, and lg: padding and gap utilities tighten the cards so the checkout fits on one laptop screen.

Shipping methods are sr-only radio inputs inside label.opc-option cards; has-[:checked]: variants draw the blue border and style.css fades in the .opc-check icon. Each radio has a data-opc-cost, and the change event recalculates the totals.

Payment uses the ARIA tabs pattern: three role="tab" buttons (Card, Wallet, Bank) control three role="tabpanel" panels. The script hides inactive panels and sets disabled on their fieldset, so hidden card fields are neither validated nor submitted. The card number is grouped in blocks of four and the expiry gets an automatic slash.

The summary adds up every data-opc-line value, adds the selected shipping cost, subtracts the discount and writes the result to data-opc-total and the submit button. On submit the script checks every enabled field with checkValidity(), marks failures with aria-invalid="true" and focuses the first one. Otherwise it shows a spinner, then a confirmation with a sample order number.

Customization

  • CODES at the top of script.js: add discount codes and rates, e.g. { SAVE10: 0.1 }; validate real codes on the server.
  • data-opc-cost on each input[name="shipping"]: set the shipping prices, and update the visible price text in the same card.
  • data-opc-line on each summary price: the line total used for the subtotal.
  • blue-700 in buttons, focus rings and has-[:checked]:border-blue-700: replace with emerald-700 or zinc-900 to match your brand.
  • lg:grid-cols-[1fr_22rem] on the form: widen or narrow the summary column.
  • Remove a role="tab" button and its panel to offer fewer payment methods.
  • The setTimeout in the submit handler: replace it with fetch() to your order endpoint or payment provider SDK.

Use cases

  • Online stores: address, shipping method and payment on one page
  • Booking and ticket sites: a single checkout step with a live total
  • Checkout prototypes: test a one-page flow with card, wallet and bank payment tabs

Accessibility

Each section is a fieldset with a legend, and every input has a visible label and the right autocomplete token (cc-number, cc-exp, postal-code…). Payment tabs support Arrow Left/Right, Home and End with roving tabindex. Shipping cards show a focus outline through has-[:focus-visible]. Discount and order messages use aria-live regions, and quantity badges include sr-only text. Animations stop under prefers-reduced-motion: reduce.

Usage notes

The product photos come from Unsplash; replace them with your own. Never handle raw card numbers on your own server: use your payment provider's hosted fields in the Card panel.

One-Page Checkout with Payment Options at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Checkout
License
Free for personal and commercial use

Questions about this template

Can I use the One-Page Checkout with Payment Options code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

One-Page Checkout with Payment Options – Tailwind CSS checkout component screenshot
One-Page Checkout with Payment Options · Tailwind CSS Checkout

More Checkout

Checkout Form with Order Summary – Bootstrap 5 checkout preview

Checkout Form with Order Summary

Bootstrap 5 one-page checkout with contact, shipping, delivery and payment sections, card input masks, validation, promo code and a live order summary.

Order Summary with Coupon – Tailwind CSS checkout preview

Order Summary with Coupon

Tailwind CSS checkout order summary card with a discount code field, live totals, tax and a free shipping progress bar.