Your Cart Page React component
A three-step eCommerce flow in one block: a cart with quantity steppers and promo code, a checkout form with an order summary, and an animated order-confirmed screen.
About the Your Cart Page component
Your Cart Page is a free three-step checkout flow in one component: a cart with quantity steppers, remove buttons, a promo code field and a totals panel; a contact, shipping and payment form next to an order summary; and an Order Confirmed screen with a check mark that draws itself in. A progress bar at the top shows Step 1 of 3 and moves as you go.
Subtotal, a 10% promo discount (codes in promoCodes, matched case-insensitively), flat shippingAmount and tax at taxRate are calculated from the digits in each item's price and shown with your currency symbol. Pay Now calls onPay with the items, amounts and form values; the component doesn't validate the form or charge a card itself. Steps change with a blur, slide, fade or scale animation (animation, animationDuration) that is switched off under prefers-reduced-motion, form fields carry autocomplete hints, and the layout goes to two columns when its container is 920px wide or more.
When to use it
Use it as the cart and checkout screens of a storefront prototype, a headless commerce front end or a single-product shop, wiring onPay to your payment provider.
For the product page that feeds the cart, use Product Detail; for card number formatting on its own, use Credit Card Input.
Installation
Add the Your Cart Page component to your project with the shadcn CLI. It lands in components/your-cart-page.tsx as plain React + Tailwind CSS source you own and can edit.
npx shadcn@latest add @reactframe/your-cart-pageOr copy the source by hand and install its dependencies:
npm install motion clsx tailwind-mergeProps
<YourCartPage /> accepts 21 props (required ones are marked *).
| Prop | Type | Default |
|---|---|---|
| items* | { title: string; variant?: string; price: string; image?: string }[] | — |
| heading | string | "Your Cart" |
| checkoutLabel | string | "Checkout" |
| payLabel | string | "Pay Now" |
| confirmTitle | string | "Order Confirmed" |
| confirmBody | string | "Your order has been placed successfully." |
| orderNumber | string | "#ORD-48291" |
| shippingAmount Flat shipping cost in the currency of the prices. 0 shows "Free" at checkout. | number | 0 |
| taxRate 0.08 = 8%. | number | 0.08 |
| currency | string | "$" |
| promoCodes Promo codes that take 10% off, compared case-insensitively. | string[] | ["SAVE10"] |
| defaultValues | Partial<YourCartFormValues> | — |
- items*{ title: string; variant?: string; price: string; image?: string }[]
- headingstringDefault: "Your Cart"
- checkoutLabelstringDefault: "Checkout"
- payLabelstringDefault: "Pay Now"
- confirmTitlestringDefault: "Order Confirmed"
- confirmBodystringDefault: "Your order has been placed successfully."
- orderNumberstringDefault: "#ORD-48291"
- shippingAmount
Flat shipping cost in the currency of the prices. 0 shows "Free" at checkout.
numberDefault: 0 - taxRate
0.08 = 8%.
numberDefault: 0.08 - currencystringDefault: "$"
- promoCodes
Promo codes that take 10% off, compared case-insensitively.
string[]Default: ["SAVE10"] - defaultValuesPartial<YourCartFormValues>
Show all 21 propsShow fewer
| defaultStep | 1 | 2 | 3 | 1 |
| animation | "blur" | "slide" | "fade" | "scale" | "blur" |
| animationDuration | number | 0.7 |
| onPay | (order: YourCartOrder) => void | — |
| onViewOrder | () => void | — |
| onContinueShopping | () => void | — |
| theme | "dark" | "light" | "dark" |
| accentColor | string | "#7CDE6A" |
| className | string | — |
- defaultStep1 | 2 | 3Default: 1
- animation"blur" | "slide" | "fade" | "scale"Default: "blur"
- animationDurationnumberDefault: 0.7
- onPay(order: YourCartOrder) => void
- onViewOrder() => void
- onContinueShopping() => void
- theme"dark" | "light"Default: "dark"
- accentColorstringDefault: "#7CDE6A"
- classNamestring
Collections
Use-case pages that compare Your Cart Page with the other components that do a similar job.
npm dependencies
Installed for you by the shadcn CLI.
Your Cart Page FAQ
- Does it process payments?
- No. Pay Now calls onPay(order) with items (title, variant, quantity, unitPrice), subtotal, discount, shipping, tax, total, orderNumber and the customer fields, then shows the confirmation step. Send that to Stripe or your own backend.
- How are prices parsed?
- Each item's price is text such as "$249.00"; only its digits and decimal point are used for the math, and totals are shown as currency plus the amount, like "$ 249.00".
- How do promo codes work?
- Any code in promoCodes (default ["SAVE10"]) takes 10% off the subtotal before tax when the user clicks Apply. Editing the field removes the discount until it's applied again.
- Can I prefill the checkout form?
- Yes, pass defaultValues with any of email, phone, fullName, address, city, region, zip, card, exp and cvc. defaultStep (1, 2 or 3) opens the flow on a given step.
- Does it respect reduced motion?
- Yes. With prefers-reduced-motion, step transitions have zero duration and the check mark appears without drawing.