Checkout summary
Single-product order summary card with an optional media tile, height-spring discount lines, promo code field that morphs into a removable chip and shakes on errors, computed tax, rolling total, and pay button states.
import { CheckoutSummary } from '@uthereal/ui/checkout-summary'Checkout summary playground
Order summary
- Subtotal
- $96.00
- Yearly billingTwo months free
- −$24.00
- Sales tax (8.5%)
- $6.12
- Total
- $78.12
Encrypted payment
Overview
CheckoutSummary renders a self-contained order summary card for the final step before payment. It pairs a single product row (with an optional 44px media tile, description, price, and billing period) with an optional promo code field, a structured breakdown of subtotal, automatic adjustments, tax, and a rolling total, followed by a full-width accent pay button.
Entering a valid promo code morphs the input into a removable chip and springs a tinted discount line into the breakdown while the total rolls smoothly to the new amount. Invalid codes shake the promo field horizontally for 360ms and announce the error inline. Pressing Pay cycles the button label and icon through idle, processing, and done (or error with Try again), or submits a native <form method="post"> for hosted checkout redirects such as Stripe Checkout.
Use CheckoutSummary for a single-product checkout sidebar, pre-redirect confirmation card, or digital license purchase. For a full two-column SaaS checkout with plan cards, seat stepper, country tax selector, and card fields, use Live checkout. For prepaid AI credit top-ups with volume bonuses, use Credit top-up.
Usage
'use client'
import { CheckoutSummary } from '@uthereal/ui/checkout-summary'
export function LicenseCheckout() {
return (
<CheckoutSummary
item={{
name: 'Studio License',
description: 'All components and blocks for one team',
price: 199,
period: 'one payment',
}}
adjustments={[
{
id: 'launch',
label: 'Launch discount',
amount: -50,
note: '38 of 50 left',
},
]}
coupon={{
onApply: async (code) => {
const res = await fetch('/api/coupon', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ code }),
})
return res.json()
},
}}
tax={{ label: 'Tax', note: 'Calculated at checkout' }}
form={{ action: '/api/checkout', fields: { plan: 'studio' } }}
payLabel={(total) => `Continue to payment, ${total}`}
/>
)
}Omit coupon and onPay/form to run the built-in local simulation (nothing leaves the browser: WELCOME10 applies a sample $7.20 discount, and pressing Pay simulates a 1.4s charge). Always compute final totals and validate promo codes on your server.
Examples
European VAT order without promo field
Set currency, locale, a computed VAT rate, and showCoupon: false for a fixed-price regional license order with a pre-applied launch discount and invoice footnote.
License summary
- Subtotal
- €240
- Launch discount18 of 50 left
- −€40
- VAT (19%)
- €38
- Total
- €238
Encrypted payment
Includes a VAT invoice for EU businesses. Instant access after payment.
Deferred tax and gated checkout
Omit tax.rate to display a muted note instead of a calculated tax figure, and set disabled: true to present the full order summary before checkout opens.
Pre-order summary
- Subtotal
- $4,200
- Estimated tax
- Calculated at checkout
- Total
- $4,200
Checkout opens Nov 1
Final tax is calculated from your billing address once checkout opens.
Pricing, promo codes, and pay states
Calculation rules
| Rule | Behavior |
|---|---|
| Subtotal | Starts at item.price. Automatic adjustments and the applied coupon are summed; the discounted subtotal floors at 0. |
| Discounts | Negative amount values render tinted with --ui-success and a typographic minus sign (−). |
| Tax | When tax.rate is set, computed as round(subtotal × rate, 2). Without rate, renders tax.note or "Calculated at checkout". |
| Decimals | Displays zero decimals when every shown figure is a whole number, switching to two decimals as soon as any figure is fractional. |
Pay button lifecycle
| State | Visual indicator | Trigger |
|---|---|---|
idle | Accent fill, lock icon (or arrow with form). | Initial state; resets automatically on browser back-forward restore. |
processing | Accent fill, spinning loader, "Processing". | Native form submit or active onPay promise; button is disabled. |
done | Success fill (--ui-success), check icon. | onPay resolves; displays successLabel (default "Paid"). |
error | Accent fill, "Try again" + role="alert" note. | onPay rejects; remains clickable to retry. |
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Order summary" | Card heading, e.g. "Order summary"; also the section’s accessible name. |
item | CheckoutItemDefault: {"name":"Field notes, yearly","description":"Unlimited notebooks and sync for one person","price":96,"period":"per year"} | The product: name, price, and optional description, period, and media tile image. Defaults to a sample order. |
adjustments | CheckoutLine[]Default: [{"id":"annual","label":"Yearly billing","amount":-24,"note":"Two months free"}] | Automatic lines under the subtotal, each with id (unique, "coupon" reserved), label, amount (negative for a discount, tinted), and optional note. Defaults to one sample yearly discount. |
tax | CheckoutTaxDefault: {"label":"Sales tax (8.5%)","rate":0.085} | Tax line. With rate the amount is computed from the discounted subtotal; without it the note, or "Calculated at checkout", shows instead of an amount. |
currency | stringDefault: "$" | Symbol shown before every amount, e.g. "$" or "€". Defaults to $. |
showCoupon | booleanDefault: true | Show the promo code field. With the React-only coupon callback the host validates codes; without it the built-in sample validation applies only the WELCOME10 code. |
couponPlaceholder | stringDefault: "Try WELCOME10" | Placeholder text of the promo code field. Defaults to "Try WELCOME10". |
secureNote | stringDefault: "Encrypted payment" | Line beside the lock under the pay button. Defaults to "Encrypted payment". |
successLabel | stringDefault: "Paid" | Pay button label once the payment resolves. Defaults to "Paid". |
disabled | booleanDefault: false | Show the pay button but block payment, e.g. while checkout is not open yet. |
footnote | string— | Small print under the pay button. |
payAction | string— | Registered host action requested when the pay button is pressed. |
locale | string— | BCP 47 locale for formatting amounts. Inherited from the provider when omitted; never read from the runtime. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | CheckoutSummaryThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | CheckoutSummaryMotionOptionsDefault: {} | Line height spring, pay label swap, and invalid-code shake overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
CheckoutItemaccepts{ name, price, description?, period?, mediaUrl? }.mediaUrlaccepts anhttps://URL, a relative path, or adata:image/URI.CheckoutLineaccepts{ id, label, amount, note? }. Adjustment IDs must be unique, and"coupon"is reserved for the applied promo line.CheckoutTaxaccepts{ label, rate?, note? }, whererateis a fraction between0and1(for example0.085for8.5%).
React integration
| Prop | Purpose |
|---|---|
coupon | { onApply: (code) => Promise<CheckoutCouponResult> } validating promo codes on your server (amount is a positive discount value). |
payLabel(total) | Customizes the idle pay button text with the formatted total string. Defaults to `Pay ${total}`. |
onPay() | Runs a client-side payment; resolve to enter done, reject to enter error with "Try again". |
form | { action, fields? } rendering a native <form method="post"> with hidden inputs for hosted checkout redirects. |
media | React node rendered inside the 44px media tile, taking precedence over item.mediaUrl. |
onAction(action) | Called with payAction when the pay button is activated. |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme, applied to the root <section>. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
Tab | Moves through the promo code input, Apply (or chip Remove), and the Pay button. |
Enter | Submits the promo code from the input; an empty input keeps focus. |
Enter / Space | Activates Apply, removes an applied promo chip (returning focus to the input), or pays. |
- The root
<section>is labelled bytitlewith an<h3>heading. - The promo input pairs with a visually hidden
<label>, setsaria-invalidandaria-describedbyon failure, and renders errors insiderole="alert". - The checking spinner renders a visually hidden
"Checking code"label so the Apply button keeps an accessible name while busy. - The total renders its full formatted string in visually hidden text while the rolling digits stay
aria-hidden="true". - The pay button sets
aria-live="polite"so"Processing","Paid", and"Try again"are announced automatically. - Container queries hide the product description below
360pxcontainer width; logical properties mirror cleanly in RTL (dir="rtl") withunicode-bidi: plaintexton amounts, and@media (forced-colors: active)maps borders, button fills, errors, and focus outlines to system colors.
Motion & theming
Adjustment and coupon lines open and close on a critically damped height spring (smooth, zero bounce) with padding animated alongside height. Applying a code morphs the form into the chip, invalid codes trigger a 360ms horizontal shake, the total rolls through RollingNumber, and pay button labels rise 8px on state transitions.
Under prefers-reduced-motion: reduce, the horizontal shake, height springs, press scales, and vertical travel turn off while label and chip swaps keep a 120ms opacity crossfade and the spinner slows to 1.6s. Setting motion="none" makes every transition immediate (0ms) and stops spinner animation.
theme accepts mode, accent, and typed tokens across these groups:
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-shadow, --ui-disabled-opacity, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength |
shape | --ui-radius-sm, --ui-popup-radius, --ui-surface-radius |
include | --ui-font-display |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, CheckoutSummary is a leaf block. Configure a single product item with realistic prices, use unique adjustment IDs (never "coupon"), pass negative numbers for discounts, and wire payAction to a registered host action. See Building with agents.
{
"type": "CheckoutSummary",
"props": {
"title": "Order summary",
"item": {
"name": "Pro Annual",
"description": "Unlimited workspaces and sync",
"price": 144,
"period": "per year"
},
"adjustments": [
{
"id": "annual",
"label": "Annual savings",
"amount": -24,
"note": "Two months free"
}
],
"tax": {
"label": "Sales tax (8.5%)",
"rate": 0.085
},
"payAction": "submit_checkout_order"
},
"children": []
}