Cart Line Item
ProNewOne product in a cart: picture, name, options, a stepper, a compare-at price and a low-stock notice, in a row that never reflows as amounts change.
Installation
pnpm dlx shadcn@latest add @viewport/cart-line-item
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| title* | stringThe product's name. | — |
| href | stringMakes the name a link to the product. | — |
| details | stringThe chosen options, e.g. "Oat · Regular". | — |
| media* | React.ReactNodeThe picture: an `img`, or any element that fills the square. | — |
| price* | stringThe line total, formatted. | — |
| compareAt | stringThe price before a discount, formatted. Shown struck through and read as "was". | — |
| quantity* | number | — |
| onQuantityChange* | (quantity: number) => void | — |
| onRemove* | () => void | — |
| max | numberThe most that can be bought, e.g. the stock left. | — |
| notice | stringA short notice under the details, e.g. "Only 2 left". | — |
| className | string | — |
Accessibility
- The name is a heading and can be a link.
- A struck-through price is read as “Was”.
- Remove is named after the product.
- Respects prefers-reduced-motion.