---
title: "Cart Item"
description: "Displays one selected product with quantity and removal controls - picture, name, options, a quantity stepper, the line total and remove."
slug: "cart-item"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, DocLink, SkillField, SkillText, SkillRow, ApiPill } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="cart-item" title="Cart Item" component="cart-item">
  Displays one selected product with quantity and removal controls - picture, name, options, a quantity stepper, the line total and remove. Part of the <DocLink href="website-shop.html">Shop</DocLink> blocks.
</PageHeader>

<SkillPanel component="cart-item">
  <SkillField label="Native basis">
<SkillText>An <code>&lt;li&gt;</code> in the cart list: thumbnail, name link, chosen options and unit price, a Number Input (with a visually hidden label naming the product), the line total as <code>&lt;output for&gt;</code> and a remove button.</SkillText>
  </SkillField>

  <SkillField label="Built from">
<SkillText><DocLink href="number-input.html">Number Input</DocLink>.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/output" title="a computed result"><code>&lt;output&gt;</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode" title="the right on-screen keyboard"><code>inputmode</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries" title="the layout follows the block width, not the viewport"><code>Container queries</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.mk-cart-list</code>
    <code>.mk-cart-item</code>
    <code>.mk-cart-item-image</code>
    <code>.mk-cart-item-info</code>
    <code>.mk-cart-item-name</code>
    <code>.mk-cart-item-options</code>
    <code>.mk-cart-item-unit</code>
    <code>.mk-cart-item-qty</code>
    <code>.mk-cart-item-total</code>
    <code>.mk-cart-item-remove</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Data attributes">
<SkillText><code>data-variant="compact"</code>.</SkillText>
  </SkillField>
</SkillPanel>

```html example label="Cart" hint="Rows in a list (.mk-cart-list): thumbnail, name link, options and unit price, a Number Input (its hidden label names the product), the line total (<output for>) and a labelled remove button." previewStyle="align-items:stretch;"
<ul class="mk-cart-list" aria-label="Cart, 2 items">
  <li class="mk-cart-item">
    <img class="mk-cart-item-image" src="images/photos/s-prod-shirt-240x300.webp" alt="" />
    <div class="mk-cart-item-info">
      <h3 class="mk-cart-item-name"><a href="#">Linen shirt</a></h3>
      <p class="mk-cart-item-options">Sand · Size M</p>
      <p class="mk-cart-item-unit">€64.00 each</p>
    </div>
    <div class="mk-cart-item-qty">
      <label class="sr-only" for="ci-1-qty">Quantity of Linen shirt</label>
      <div class="number-input"
        ><button type="button" data-action="decrement" aria-label="Decrease quantity of Linen shirt">−</button
        ><input type="number" id="ci-1-qty" name="qty" min="0" max="10" value="1" inputmode="numeric" /><button
          type="button"
          data-action="increment"
          aria-label="Increase quantity of Linen shirt"
          >+</button
        ></div
      >
    </div>
    <output class="mk-cart-item-total" for="ci-1-qty">€64.00</output>
    <button class="mk-cart-item-remove" type="button" aria-label="Remove Linen shirt from cart"
      ><i data-lucide="x"></i
    ></button>
  </li>
  <li class="mk-cart-item">
    <img class="mk-cart-item-image" src="images/photos/s-prod-mug-240x300.webp" alt="" />
    <div class="mk-cart-item-info">
      <h3 class="mk-cart-item-name"><a href="#">Stoneware mug</a></h3>
      <p class="mk-cart-item-options">Oat · 350 ml</p>
      <p class="mk-cart-item-unit">€22.00 each</p>
    </div>
    <div class="mk-cart-item-qty">
      <label class="sr-only" for="ci-2-qty">Quantity of Stoneware mug</label>
      <div class="number-input"
        ><button type="button" data-action="decrement" aria-label="Decrease quantity of Stoneware mug">−</button
        ><input type="number" id="ci-2-qty" name="qty" min="0" max="10" value="2" inputmode="numeric" /><button
          type="button"
          data-action="increment"
          aria-label="Increase quantity of Stoneware mug"
          >+</button
        ></div
      >
    </div>
    <output class="mk-cart-item-total" for="ci-2-qty">€44.00</output>
    <button class="mk-cart-item-remove" type="button" aria-label="Remove Stoneware mug from cart"
      ><i data-lucide="x"></i
    ></button>
  </li>
</ul>
```

```html example label="Mini cart" hint="data-variant='compact': a small picture and &quot;Qty 2&quot; as text - for a cart sheet or popover." previewStyle="align-items:stretch;"
<ul class="mk-cart-list" aria-label="Cart" style="max-width: 22rem">
  <li class="mk-cart-item" data-variant="compact">
    <img class="mk-cart-item-image" src="images/photos/s-prod-shirt-240x300.webp" alt="" />
    <div class="mk-cart-item-info">
      <h3 class="mk-cart-item-name"><a href="#">Linen shirt</a></h3>
      <p class="mk-cart-item-options">Sand · M</p>
      <p class="mk-cart-item-unit">€64.00 each</p>
    </div>
    <div class="mk-cart-item-qty"><span>Qty 1</span></div>
    <output class="mk-cart-item-total" for="cc-1-qty">€64.00</output>
    <button class="mk-cart-item-remove" type="button" aria-label="Remove Linen shirt from cart"
      ><i data-lucide="x"></i
    ></button>
  </li>
  <li class="mk-cart-item" data-variant="compact">
    <img class="mk-cart-item-image" src="images/photos/s-prod-mug-240x300.webp" alt="" />
    <div class="mk-cart-item-info">
      <h3 class="mk-cart-item-name"><a href="#">Stoneware mug</a></h3>
      <p class="mk-cart-item-options">Oat</p>
      <p class="mk-cart-item-unit">€22.00 each</p>
    </div>
    <div class="mk-cart-item-qty"><span>Qty 2</span></div>
    <output class="mk-cart-item-total" for="cc-2-qty">€44.00</output>
    <button class="mk-cart-item-remove" type="button" aria-label="Remove Stoneware mug from cart"
      ><i data-lucide="x"></i
    ></button>
  </li>
</ul>
```

<SourceFiles component="cart-item" section="css" />

</DocPage>
