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 playgroundSubtotal, 2 items
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
npm i @ashutoshswamy/smouiUsage
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
More cards components
- AvatarGroupA tucked stack of avatars. Point at one and it lifts, its neighbours part around it and a tooltip names it. The +N chip opens the rest as a list.
- BadgeA short status label in five tones, soft or solid, with an optional icon. A number inside rolls to its new value.
- BookingCardPick a day, pick a time, book. One pill slides between choices and the button names what you are about to book.
- CommentThreadA conversation that reads as one. Replies hang off a thin rail and fold away, likes count as they change, and the reply box opens in place and grows as you type.
- CompareStatThis period against the last. Totals and the change on top, paired bars below; point at a pair and the caption names both numbers.
- ContactCardA card that turns over on a spring. The front is who they are; the back is how to reach them, and each line copies on a press.