Documentation
Feedback
Guides
Storefront Development

Storefront Development
Storefront development

CartItem

Displays the summary information of a product in the cart.

The CartItem component displays the summary information of a product in the cart. It's a compound component that combines product image, summary details, pricing, and quantity controls. Typical use cases include:
  • Displaying items in shopping cart sidebars and drawers.
  • Showing cart contents in checkout flows.
  • Listing items in minicart dropdowns.
  • Presenting cart items in cart pages.
Example
Code
appleblack
Apple Magic Mouse

Color: Black

Size: Medium

Original price:$999Price:$950.04

Usage

Import the component


_10
import { CartItem, CartItemImage, CartItemSummary } from "@faststore/ui";

Import styles

To apply styles, include the following in your stylesheet:

_10
@import "@faststore/ui/src/components/molecules/CartItem/styles.scss";


Examples

Unavailable

Example
Code
appleblack
Apple Magic Mouse

Color: Black

Size: Medium

Original price:$999Price:$950.04

With discount

Example
Code
appleblack
Apple Magic Mouse

Color: Black

Size: Medium

Original price:$999Price:$950.04

Design tokens

Local tokenDefault value/Global token linked
--fs-cart-item-paddingvar(--fs-spacing-3)
--fs-cart-item-bkg-color
var(--fs-control-bkg)
--fs-cart-item-border-widthvar(--fs-border-width)
--fs-cart-item-border-color
var(--fs-border-color-light)
--fs-cart-item-border-radiusvar(--fs-border-radius)

Design tokens: Image

Cart item images use consistent sizing and border radius to maintain visual consistency and alignment within the cart item layout.
Local tokenDefault value/Global token linked
--fs-cart-item-image-border-radiusvar(--fs-cart-item-border-radius)
--fs-cart-item-image-widthvar(--fs-spacing-8)
--fs-cart-item-image-heightvar(--fs-cart-item-image-width)

Design tokens: Title

Title tokens control typography and spacing for the product name, ensuring clear readability and proper visual hierarchy within the cart item.
Local tokenDefault value/Global token linked
--fs-cart-item-title-margin-bottomvar(--fs-spacing-0)
--fs-cart-item-title-line-height1.2
--fs-cart-item-title-color
var(--fs-color-text)

Design tokens: SKUs

SKU tokens manage the display of product variations (size, color, etc.), using compact typography and spacing to present multiple attributes without overwhelming the cart item layout.
Local tokenDefault value/Global token linked
--fs-cart-item-skus-margin-topvar(--fs-spacing-0)
--fs-cart-item-skus-text-sizevar(--fs-text-size-legend)
--fs-cart-item-skus-text-color
var(--fs-color-text-light)
--fs-cart-item-skus-line-heightvar(--fs-text-size-body)
--fs-cart-item-skus-column-gapvar(--fs-spacing-1)
--fs-cart-item-skus-row-gapvar(--fs-spacing-0)

Design tokens: Prices

Price tokens control spacing between price elements, ensuring clear presentation of current and list prices when discounts are applied.
Local tokenDefault value/Global token linked
--fs-cart-item-price-gapvar(--fs-spacing-1)

Data attributes

You can target and override CartItem styles using the following data attributes:
data-fs-cart-item
data-fs-cart-item="unavailable"
data-fs-cart-item-content
data-fs-cart-item-image
data-fs-cart-item-summary
data-fs-cart-item-title
data-fs-cart-item-skus
data-fs-cart-item-remove-button
data-fs-cart-item-prices
data-fs-cart-item-actions

Props

CartItem

NameTypeDescriptionDefault
testIdstringID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).fs-cart-item
pricePriceDefinitionSpecifies product Price.
quantitynumberSpecifies the quantity of items of the same product.
unitMultipliernumberControls by how many units the value advances
useUnitMultiplierfalse | trueControls wheter you use or not the unitMultiplier
unavailablefalse | trueSpecifies that this product is unavailable.
removeBtnPropsPartial<IconButtonProps>Props for the Remove from cart IconButton component.
onQuantityChange(value: number) => voidEvent emitted when product quantity value is changed.

CartItemImage

NameTypeDescriptionDefault
testIdstringID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).fs-cart-item-image

CartItemSummary

NameTypeDescriptionDefault
testIdstringID to find this component in testing tools (e.g.: Cypress, Testing Library, and Jest).fs-cart-item-summary
title*stringSpecifies the product's title.
activeVariations{ label: string; option: string; }[]Array of the product's chosen variations.[]

Other Resources

PriceDefinition

NameTypeDescriptionDefault
valuenumberThe raw price value.
listPricenumberProduct's list price
formatterPriceFormatter(price: number, variant: PriceVariant) => ReactNode

Best Practices

✅ Do's

  • Always include a product image using CartItemImage to help users identify items in their cart.
  • Display clear pricing information, including both current price and list price when applicable.
  • Show product variations (size, color, etc.) using activeVariations in CartItemSummary to help users distinguish between similar items.
  • Use the unavailable prop to clearly indicate when an item is no longer available for purchase.
  • Ensure product images have descriptive alt text for accessibility.
  • Display accurate quantity information to help users track their cart contents.

❌ Don'ts

  • Don't omit essential product information such as title, price, or image.
  • Don't use generic placeholder images when product images are available.
  • Don't hide quantity controls or make them difficult to access.
  • Avoid displaying cart items without proper spacing or visual separation between items.
  • Don't forget to handle unavailable items appropriately—either remove them or clearly mark them as unavailable.

Contributors
4
Photo of the contributor
Photo of the contributor
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
4
Photo of the contributor
Photo of the contributor
Photo of the contributor
Photo of the contributor
Was this helpful?
Suggest edits (GitHub)
On this page