Cart

CartDrawer

Slide-over cart drawer with items, quantities, subtotal, and checkout actions.

CartDrawer

A slide-over sidebar that displays cart items with thumbnails, names, prices, quantity selectors, and remove buttons. Includes subtotal, empty state, and checkout/view-cart actions.

Preview

Usage

<CCartDrawer :cart="cart" @update:quantity="updateQty" @remove="removeItem">
  <template #trigger>
    <UButton icon="i-heroicons-shopping-bag" />
  </template>
</CCartDrawer>

Custom Product URLs

<CCartDrawer
  :cart="cart"
  :resolve-product-url="(item) => `/shop/${item.productSlug}`"
/>

Props

PropTypeDefaultDescription
cartCart | nullrequiredCart data
itemsCartItem[]Override cart items
itemCountnumberOverride item count
loadingbooleanfalseLoading state
titlestring'Shopping Cart'Drawer header
checkoutLabelstring'Checkout'Checkout button label
checkoutTostring'/checkout'Checkout route
viewCartLabelstring'View Cart'View cart button label
viewCartTostring'/cart'View cart route
resolveProductUrl(item: CartItem) => stringCustom product URL resolver

Events

EventPayloadDescription
update:quantity{ itemId: string, quantity: number }Item quantity changed
removestringItem removed (item ID)

Slots

SlotScoped PropsDescription
triggerDrawer open trigger button
bodyCustom cart body content
footerCustom footer with totals/actions

Example: Custom Trigger with Badge

<CCartDrawer :cart="cart">
  <template #trigger>
    <UButton icon="i-heroicons-shopping-bag" variant="ghost">
      <UBadge v-if="cart?.itemCount" floating color="primary">{{ cart.itemCount }}</UBadge>
    </UButton>
  </template>
</CCartDrawer>