Skip to content
Haze UI

AI in-chat checkout

In-chat merchant checkout card with quantity stepper, dynamic shipping and tax totals, animated pay progress, and collapsible receipt.

pnpm dlx shadcn@latest add @haze/ai-checkout
Open preview in a new tab
Livesmall script

When to use

  • Completing a fast reorder or one-item purchase directly inside an assistant conversation
  • Showing live subtotal, free-shipping threshold, tax calculation, and saved card confirmation before charging
  • Folding a finished purchase card into a compact receipt row without leaving the chat thread

When not to use

  • Collecting full billing addresses, multi-item carts, or new card details; use payment-card-input in a dedicated checkout flow
  • Tracking a shipment after checkout has completed; use ai-order-status instead

Installation

Add the Haze registry to components.json once, then install AI in-chat checkout with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/ai-checkout
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
idstring"haze-ai-checkout"Unique prefix for section heading and aria-labelledby IDs.
headingstring"In-chat checkout"Screen-reader section heading for landmark navigation.
userPromptstring"Reorder the coffee beans I got last month"User message bubble requesting the purchase.
assistantReplystring"Same as October, two bags of Ethiopia Worka. Want me to place it?"Assistant reply introducing the checkout card.
merchantstring"Verve Roasters"Merchant title shown in the checkout header.
itemNamestring"Ethiopia Worka"Product name inside the order line.
itemMetastring"Whole bean, 250 g"Variant or weight detail shown under the product name.
unitPricenumber19Price per unit in USD used for live total recalculation.
initialQuantitynumber2Starting item quantity between 1 and 8.
freeShippingAtnumber35Subtotal threshold at which shipping becomes free.
shippingFeenumber4.5Flat shipping charge applied below the free-shipping threshold.
taxRatenumber0.08Decimal tax rate applied to the subtotal.
cardSummarystring"Card •••• 4242 · Arrives in 2 days"Saved payment method and delivery estimate line.
orderCodestring"VR-8042"Order reference displayed in the collapsed paid receipt.
classstring–Extra classes on the outer section.

Keyboard interactions

Tab
Move between the quantity stepper buttons, the Pay button, and Start over after payment
EnterSpace
Adjust item quantity, submit the simulated payment, or reset the checkout card

Accessibility

  • Quantity stepper buttons carry explicit Decrease quantity and Increase quantity labels, disable at bounds (1 and 8), and announce recalculated totals through a polite status region.
  • Payment progress honors prefers-reduced-motion and shifts focus cleanly to the Start over action once the checkout card folds into the paid receipt.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI block "AI in-chat checkout" with `npx shadcn@latest add @haze/ai-checkout`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AiCheckout from "@/components/haze/blocks/ai-checkout.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/ai-checkout.md

  • Customize with real content

    Adapt the Haze ai-checkout block for our product. Replace the demo values of these props with our real content: id, heading, userPrompt, assistantReply, merchant, itemName, itemMeta, unitPrice, initialQuantity, freeShippingAt, shippingFee, taxRate, cardSummary, orderCode, class. Keep the layout, the heading level rules and these accessibility details: Quantity stepper buttons carry explicit Decrease quantity and Increase quantity labels, disable at bounds (1 and 8), and announce recalculated totals through a polite status region. Payment progress honors prefers-reduced-motion and shifts focus cleanly to the Start over action once the checkout card folds into the paid receipt. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using ai-checkout, check it fits: use it when completing a fast reorder or one-item purchase directly inside an assistant conversation; showing live subtotal, free-shipping threshold, tax calculation, and saved card confirmation before charging; folding a finished purchase card into a compact receipt row without leaving the chat thread. Avoid it when collecting full billing addresses, multi-item carts, or new card details; use payment-card-input in a dedicated checkout flow; tracking a shipment after checkout has completed; use ai-order-status instead. Alternatives: @haze/payment-card-input, @haze/ai-order-status, @haze/ai-send.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog