# CartDrawer

> The bag a shop slides in from the side: the lines, a note such as a free-shipping meter, the subtotal and the way to checkout, in a drawer the header's bag link opens.

```ts
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.

## Examples

```tsx
<CartDrawer id="bag" title="Your bag" subtotal={<Amount value={4800} currency="EUR" />} checkoutHref="/checkout" cartHref="/cart" labels={{ checkout: "Checkout", viewCart: "View bag", close: "Close" }}><ul>…</ul></CartDrawer>
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `id` | `string` | The dialog's id, which CartDrawer.Trigger names as its `drawer`. |
| `title` | `RemixNode` |  |
| `children?` | `RemixNode` | The lines, usually a `<ul>` of `CartLine`; leave it out for an empty bag. |
| `empty?` | `RemixNode` | Shown in place of the lines, subtotal and checkout when the bag is empty. |
| `subtotal` | `RemixNode` | The subtotal as the reader sees it, set beside its own label by the caller. |
| `note?` | `RemixNode` | Above the subtotal, such as a free-shipping meter. |
| `checkoutHref` | `string` |  |
| `cartHref` | `string` |  |
| `labels` | `Labels` |  |


### CartDrawer.Trigger

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

| Prop | Type | Description |
| --- | --- | --- |
| `drawer` | `string` | The id of the CartDrawer it opens. |
| `href` | `string` | The cart page, followed when the drawer is absent or the page has no script. |
| `count` | `number` | How many items the bag holds; the badge hides at zero. |
| `label` | `string` | The link's name, such as "Bag"; the count is appended for assistive tech. |
| `countLabel?` | `string` | Appended to the name with `{n}` for the count. @default "{n} items" |

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

