Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

CartItem

Use CartItem to display a single product line in the cart. It composes slots for the product image, title, price, quantity control, and messages, and calls back when the shopper changes the quantity or removes the item.

The SDK CartItem showing a product line with image, title, price, and quantity control.
import { CartItem } from '@dropins/tools/components.js';
PropTypeReq?Description
ariaLabelstringNoAccessible name for the component.
imageVNodeNoProduct image.
titleVNodeNoTitle of the product.
priceVNodeNoPrice of each item.
rowTotalFooterVNodeNoContent displayed right below the total row price.
taxIncludedbooleanNoRender the tax-included message. Defaults to false.
taxExcludedbooleanNoRender the tax-excluded message. Defaults to false.
totalVNodeNoTotal price of the product.
totalExcludingTaxVNodeNoTotal price of the product excluding tax.
skuVNodeNoThe product SKU.
quantitynumberNoThe quantity of the product.
quantityContentVNodeNoCustom content that replaces the quantity control.
descriptionVNodeNoDescription of the product.
attributesVNodeNoProduct attributes.
footerVNodeNoFooter content displayed at the bottom of the item.
configurations{ [key: string]: any }NoSelected product options as key-value pairs, such as Color and Size.
warningVNodeNoA warning message.
alertVNodeNoAn alert message.
discountVNodeNoA discount message.
savingsVNodeNoA savings message.
actionsVNodeNoAction controls, such as a move-to-wishlist button.
removeContentVNodeNoCustom content for the remove control.
loadingbooleanNoRender the loading skeleton. Defaults to false.
updatingbooleanNoRender the updating state. Defaults to false.
onRemove() => voidNoHandler called when the shopper removes the item.
onQuantity(value: number) => voidNoHandler called when the shopper changes the quantity.
quantityType'stepper' | 'dropdown'NoQuantity input type. Defaults to stepper.
dropdownOptions{ value: string; text: string }[]NoOptions for the quantity dropdown when quantityType is dropdown.

CartItem also accepts standard <div> HTML attributes (for example, className), except title and loading. When loading is true, the component renders a CartItemSkeleton placeholder instead of its content.

Render a cart item with an image, title, price, and quantity control. Build the slot content with h, and use the Image and Price components for the media and pricing.

import { CartItem, Image, Price, provider } from '@dropins/tools/components.js';
import { h } from '@dropins/tools/preact.js';
await provider.render(CartItem, {
ariaLabel: 'Product name',
image: h(Image, { src: '/media/product.jpg', width: '132', height: '184', alt: 'Product name' }),
title: h('div', {}, 'Product name'),
sku: h('div', {}, 'SKU: 59YK7'),
price: h(Price, { amount: 53.99 }),
quantity: 1,
onQuantity: (value) => yourUpdateQuantity(value),
onRemove: () => yourRemoveItem(),
})(document.querySelector('.cart-item'));
  • CartList — wrap multiple cart items in a single list.
  • Price — format the prices shown in each item.