Skip to content

Organisms · Checkout form

Checkout form

Shipping, delivery and payment in three steps, with the order summary beside them. It's a demo: no payment is ever taken, and the card fields say so.

Best for
A demo checkout: shipping, delivery and payment in three steps beside the order summary.
Not for
Taking a real payment. It's a demo and never charges.

This page as Markdown, a plain-text copy for a coding agent (an AI tool that writes code).

Examples

Three steps, a demo order

Checkout

  1. Shipping, current

  2. Delivery, not started

  3. Payment, not started

Step 1 of 3: Shipping

Only for questions about delivery.

Order summary

  • Kestrel C carbine replica, quantity 1€139.00
  • Prism holo sight, quantity 2€98.00
  • Beam 600 rail light, quantity 1€24.00
Subtotal
€261.00
Delivery
Chosen at step 2
Total
€261.00
Code
tsx
const LINES: CartLine[] = [  { id: 'kestrel-c', name: 'Kestrel C carbine replica', unitPrice: 13900, quantity: 1 },  { id: 'prism-holo-sight', name: 'Prism holo sight', unitPrice: 4900, quantity: 2 },  { id: 'beam-600', name: 'Beam 600 rail light', unitPrice: 2400, quantity: 1 },]​const COUNTRIES = [  { value: 'ie', label: 'Ireland' },  { value: 'ro', label: 'Romania' },  { value: 'de', label: 'Germany' },  { value: 'fr', label: 'France' },  { value: 'es', label: 'Spain' },]​const wait = (ms: number) => new Promise(resolve => window.setTimeout(resolve, ms))​<CheckoutForm lines={LINES} countries={COUNTRIES} onPlaceOrder={() => wait(800).then(() => undefined)} headingLevel={3} />

Anatomy

PartWhat it is
StepperShows where the person is. It isn't clickable, so nobody can skip to a step whose fields don't exist yet.
Step headingRead as 'Step 2 of 3: Delivery' by a screen reader. Focus (where keyboard input goes) lands here on Continue and Back.
Error summaryLists the step's missing or wrong fields and takes focus. Each entry jumps to its field.
Delivery optionsA radio group with prices, and nothing picked in advance.
BillingUses the shipping address by default. Unticking the box asks for a billing address.
Demo noticeAn info Alert above the card fields saying no payment is taken.
Order summaryLines, subtotal, delivery and total, formatted by formatMoney.
ConfirmationA status line that's always on the page and confirms the order.
Placement alertAlso always on the page. If onPlaceOrder rejects, or resolves { error } with a specific message, this alert says so, instead of the button just quietly stopping being busy. Everything already typed stays put for another try.

Props

linesCartLine[]
Required. What's being bought. The order summary lists them.
countriesSelectOption[]
Required. The options for the country Select.
deliveryOptionsDeliveryOption[]Default DELIVERY_OPTIONS
Prices in the currency's smallest unit. Zero shows as Free.
onPlaceOrder(order: CheckoutOrder) => void | { error: string } | Promise<void | { error: string }>
Required. Gets the contact details, addresses, delivery id and total, and never a card field. If it rejects, an alert appears that lets the person try again, so the failure isn't lost. Resolving { error } shows that specific message in the same alert.
headingLevel2 | 3Default 2
The level of the 'Checkout' heading. Steps and the order summary sit one level below it, and never below ErrorSummary's own fixed h4 (level-4 heading).
currencystringDefault 'EUR'
Passed to formatMoney.
localestringDefault 'en-IE'
Passed to formatMoney.
classNamestring
Merged with the root classes. Later Tailwind utilities win.
refRef<HTMLDivElement>
The root.

Keyboard

KeysResult
TabMoves through the fields, then Back and Continue.
EnterIn a field, goes on to the next step, or places the order on the last one.
↑↓In the delivery options, moves and picks.
SpaceOn the billing checkbox, toggles it.

Do and don't

Do

  • Pass the cart lines, so the order summary and the total come from the same numbers.
  • Keep the demo notice whenever the card fields are fake.
  • Store prices in the currency's smallest unit (cents for EUR).

Don't

  • Don't make the Stepper clickable. Back and Continue move between steps.
  • Don't ask for the billing address unless it's different from shipping.
  • Don't validate a card number in a demo. Nothing's charged.