UI

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

Field notes, yearlyUnlimited notebooks and sync for one person$96.00per year
Subtotal
$96.00
Yearly billingTwo months free
−$24.00
Sales tax (8.5%)
$6.12
Total
$78.12

Encrypted payment

Loading interactive preview…

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

Studio Team LicenseAll components and blocks for one team€240one payment
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

Enterprise Annual Seat Pack25 seats with SAML SSO and audit logs$4,200per year
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

RuleBehavior
SubtotalStarts at item.price. Automatic adjustments and the applied coupon are summed; the discounted subtotal floors at 0.
DiscountsNegative amount values render tinted with --ui-success and a typographic minus sign (−).
TaxWhen tax.rate is set, computed as round(subtotal × rate, 2). Without rate, renders tax.note or "Calculated at checkout".
DecimalsDisplays zero decimals when every shown figure is a whole number, switching to two decimals as soon as any figure is fractional.

Pay button lifecycle

StateVisual indicatorTrigger
idleAccent fill, lock icon (or arrow with form).Initial state; resets automatically on browser back-forward restore.
processingAccent fill, spinning loader, "Processing".Native form submit or active onPay promise; button is disabled.
doneSuccess fill (--ui-success), check icon.onPay resolves; displays successLabel (default "Paid").
errorAccent 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.

ArgumentType / defaultDescription
titlestringDefault: "Order summary"Card heading, e.g. "Order summary"; also the section’s accessible name.
itemCheckoutItemDefault: {"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.
adjustmentsCheckoutLine[]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.
taxCheckoutTaxDefault: {"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.
currencystringDefault: "$"Symbol shown before every amount, e.g. "$" or "€". Defaults to $.
showCouponbooleanDefault: trueShow 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.
couponPlaceholderstringDefault: "Try WELCOME10"Placeholder text of the promo code field. Defaults to "Try WELCOME10".
secureNotestringDefault: "Encrypted payment"Line beside the lock under the pay button. Defaults to "Encrypted payment".
successLabelstringDefault: "Paid"Pay button label once the payment resolves. Defaults to "Paid".
disabledbooleanDefault: falseShow the pay button but block payment, e.g. while checkout is not open yet.
footnotestring—Small print under the pay button.
payActionstring—Registered host action requested when the pay button is pressed.
localestring—BCP 47 locale for formatting amounts. Inherited from the provider when omitted; never read from the runtime.
recipestudio | softDefault: "studio"Visual treatment. Both recipes preserve interaction behavior.
themeCheckoutSummaryThemeDefault: {}Color mode, accent, and typed semantic token overrides.
motionnone | subtle | expressiveDefault: "subtle"Animation preset. System reduced-motion preferences take precedence.
motionOptionsCheckoutSummaryMotionOptionsDefault: {}Line height spring, pay label swap, and invalid-code shake overrides in milliseconds.
dirltr | rtl—Reading direction; inherited from the page when omitted.
  • CheckoutItem accepts { name, price, description?, period?, mediaUrl? }. mediaUrl accepts an https:// URL, a relative path, or a data:image/ URI.
  • CheckoutLine accepts { id, label, amount, note? }. Adjustment IDs must be unique, and "coupon" is reserved for the applied promo line.
  • CheckoutTax accepts { label, rate?, note? }, where rate is a fraction between 0 and 1 (for example 0.085 for 8.5%).

React integration

PropPurpose
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.
mediaReact node rendered inside the 44px media tile, taking precedence over item.mediaUrl.
onAction(action)Called with payAction when the pay button is activated.
presetApplication defaults overridden by explicit instance arguments.
tokensCSS variables applied after the typed theme, applied to the root <section>.
ref, className, styleApplied to the root <section> element.
Native attributesid, aria-*, data-*, and remaining <section> props forwarded to the root element.

Keyboard & accessibility

KeyAction
TabMoves through the promo code input, Apply (or chip Remove), and the Pay button.
EnterSubmits the promo code from the input; an empty input keeps focus.
Enter / SpaceActivates Apply, removes an applied promo chip (returning focus to the input), or pays.
  • The root <section> is labelled by title with an <h3> heading.
  • The promo input pairs with a visually hidden <label>, sets aria-invalid and aria-describedby on failure, and renders errors inside role="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 360px container width; logical properties mirror cleanly in RTL (dir="rtl") with unicode-bidi: plaintext on 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 groupCSS 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": []
}

On this page