CartDrawer
The bag a shop slides in from the side.
View code
<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.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
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.
CartDrawerCartDrawer.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.
| Prop | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The dialog's id, which CartDrawer.Trigger names as its drawer. |
title | RemixNode | Yes | |
children | RemixNode | No | The lines, usually a <ul> of CartLine; leave it out for an empty bag. |
empty | RemixNode | No | Shown in place of the lines, subtotal and checkout when the bag is empty. |
subtotal | RemixNode | Yes | The subtotal as the reader sees it, set beside its own label by the caller. |
note | RemixNode | No | Above the subtotal, such as a free-shipping meter. |
checkoutHref | string | Yes | |
cartHref | string | Yes | |
labels | Labels | Yes |
CartDrawer.Trigger
| Prop | Type | Required | Description |
|---|---|---|---|
drawer | string | Yes | The id of the CartDrawer it opens. |
href | string | Yes | The cart page, followed when the drawer is absent or the page has no script. |
count | number | Yes | How many items the bag holds; the badge hides at zero. |
label | string | Yes | The link's name, such as "Bag"; the count is appended for assistive tech. |
countLabel | string | No | Appended to the name with {n} for the count. @default "{n} items" |
Also accepts everything in Pick<TagProps<"a">, "id" | "mix" | "title">.