Cart Item Transition
motiq/cart-item-transitionFreeComponent
An app-controlled animated cart LINE ITEM (not a full cart) — arrival, quantity/total morph, variant crossfade, price-change, limited/unavailable, removal→Undo→restore, with optimistic mutation + automatic rollback and honest failed/Retry. Never touches a backend or payment; price/inventory are app-owned. No manipulative urgency.
Live preview
live · rendered by the registry
Rendered by motiq on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.motiq.dev/r/cart-item-transition.jsonSource
1"use client";23import * as React from "react";4import { motion, AnimatePresence } from "motion/react";56import { cn } from "@/lib/utils";7import {8 useOptimisticAction,9 useReducedMotion,10 useAnimatedNumber,11 formatNumber,12 statusVars,13 type OptimisticPhase,14 type StatusTone,15} from "@/lib/motiq";1617/**18 * CartItemTransition — a single, app-controlled cart LINE ITEM that animates the19 * realistic transitions a line goes through in a real cart: it arrives, its20 * quantity and total change (optimistically, with rollback if the app's mutation21 * fails), a variant is swapped, the price changes, stock turns limited or22 * unavailable, it is removed, and it can be undone. It is NOT a cart, a23 * checkout, or a store: it never fetches, prices, decides stock, mutates a24 * backend, or touches payment. The host app owns every fact — unit price, line25 * total, availability, inventory copy, discounts — and every side-effect runs26 * through the app's async callbacks.27 *28 * What earns its keep over a static product card: an optimistic quantity/remove29 * flow with automatic rollback + an honest failed/retry state, a price-change30 * treatment that morphs the number *and* always states it as text (old → new,31 * never colour alone), a variant-replace crossfade, an app-owned32 * limited/unavailable state, and a remove → Undo affordance with correct focus33 * management throughout.34 *35 * Deliberately NOT included: no exaggerated fly-to-cart arc, no manufactured36 * urgency ("only 2 left!" countdowns), no invented discounts or stock. Inventory37 * and price copy come from the app verbatim.38 *39 * Accessibility: quantity steppers are real <button>s with explicit labels and a40 * text readout; price and price-change are rendered as text (never conveyed by41 * animation or colour alone); limited/unavailable is stated in words with an42 * icon; remove and undo are keyboard operable; focus is preserved on the pressed43 * quantity control after a change, moves to Undo after a removal, and falls back44 * to a stable control after undo; every transition renders in its final state45 * under prefers-reduced-motion. Clean-room original.46 */4748/* -------------------------------------------------------------------------- */49/* Types */50/* -------------------------------------------------------------------------- */5152/** App-owned availability of the line. Inventory *copy* is separate + verbatim. */53// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from motiq
All 100 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Activity Streamactivity-stream | motiq | Components | Free | 1 dep | |
| Adaptive Safe-Zone Gridadaptive-safe-zone-grid | motiq | Components | Free | no deps | |
| Agent Run Timelineagent-run-timeline | motiq | Components | Free | 1 dep | |
| AI Response Streamai-response-stream | motiq | Components | Free | 1 dep | |
| Animated Accordionanimated-accordion | motiq | Components | Free | 2 deps | |
| Animated Buttonanimated-button | motiq | Components | Free | 1 dep | |
| Animated Dialoganimated-dialog | motiq | Components | Free | 2 deps | |
| Animated Gridanimated-grid | motiq | Components | Free | 2 deps |
