CartSummary

A small basket. Each row opens its Add button into a stepper, and the subtotal rolls digit by digit up or down with every change. Cards.

Open playground
  • Oat milk$3.20 1 L
  • Butter croissant$2.60 baked today
    Quantity of Butter croissant2 Butter croissant in cart
  • Cherries$5.80 500 g

Subtotal, 2 items

$5.20

About

CartSummary is a React component in the Cards category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CartSummary } from "@ashutoshswamy/smoui" and set items, defaultQuantities, currency among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CartSummary } from "@ashutoshswamy/smoui";

<CartSummary items={[{ id: "milk", name: "Oat milk", price: 3.2, detail: "1 L", max: 6 }]} defaultQuantities={{ milk: 1 }} onCheckout={(q) => pay(q)} />

Props 4

items

The things on offer.

{ id; name; detail?; price; max? }[]
defaultQuantities

Starting amounts by id.

Record<string, number>
currency

ISO code. Default USD.

string
onCheckout

Enabled once something is in.

(quantities) => void