SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

CartDrawer

The bag a shop slides in from the side.

Open the bag

Your bag

  • Tidepool50×70 · Oak frame€64.00
    1
  • Fern studyInstant download€20.00
    1
You're €16.00 away from free shipping.
Subtotal€84.00
CheckoutView bag
View code
tsx
<CartDrawer.Trigger drawer="bag" href="/cart" count={cart.count} label="Bag" />

<CartDrawer
	id="bag"
	title="Your bag"
	empty="Your bag is empty."
	note={<p>You're €16.00 away from free shipping.</p>}
	subtotal={<><span>Subtotal</span><span>€84.00</span></>}
	checkoutHref="/checkout"
	cartHref="/cart"
	labels={{ checkout: "Checkout", viewCart: "View bag", close: "Close bag" }}
>
	<ul>{cart.lines.map((line) => <CartLine … action={<QuantityStepper … />} />)}</ul>
</CartDrawer>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { CartDrawer } from "@sdxc/ui/commerce";

Renders the drawer docked to the right edge: the title and close button, the lines scrolling between them and a footer holding the note, the subtotal, a full-width checkout link and a link to the cart page. An empty bag shows empty alone.

Composition

The parts the component publishes, each a static property of the host.

  • CartDrawer
  • CartDrawer.TriggerRenders the header's bag link: an icon with a count badge, named "Bag, 2 items" for assistive tech.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
idstringYesThe dialog's id, which CartDrawer.Trigger names as its drawer.
titleRemixNodeYes
childrenRemixNodeNoThe lines, usually a <ul> of CartLine; leave it out for an empty bag.
emptyRemixNodeNoShown in place of the lines, subtotal and checkout when the bag is empty.
subtotalRemixNodeYesThe subtotal as the reader sees it, set beside its own label by the caller.
noteRemixNodeNoAbove the subtotal, such as a free-shipping meter.
checkoutHrefstringYes
cartHrefstringYes
labelsLabelsYes

CartDrawer.Trigger

PropTypeRequiredDescription
drawerstringYesThe id of the CartDrawer it opens.
hrefstringYesThe cart page, followed when the drawer is absent or the page has no script.
countnumberYesHow many items the bag holds; the badge hides at zero.
labelstringYesThe link's name, such as "Bag"; the count is appended for assistive tech.
countLabelstringNoAppended to the name with {n} for the count. @default "{n} items"

Also accepts everything in Pick<TagProps<"a">, "id" | "mix" | "title">.

@sdxc/ui

Can’t find it? Contact us