Skip to content
Hazine

Mini Cart Side Drawer

Cart button that opens a modal side sheet with editable lines between a header and a pinned subtotal footer. Use it when shoppers should review and adjust the cart without leaving the page.

How it differs. Modal side sheet with three fixed zones: header with count and shipping meter, scrolling lines, pinned subtotal footer. Focus is trapped while open and returns to the cart button.

pnpm dlx shadcn@latest add @hazine/mini-cart-side-drawer

Adds 2 files, 2 shadcn primitives (button, sheet), 2 Hazine items (@hazine/heading, @hazine/use-controllable-state), 1 package (lucide-react), and the success token.

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": "https://api.hazine.dev/r/{name}.json"
  }
}

Needed once per project. Items resolve each other through the @hazine namespace.

Props15

title
string = "Your cart"
headingLevel
HeadingLevel = 2
open
boolean
defaultOpen
boolean = false
onOpenChange
(open: boolean) => void
lines
CartLine[]
defaultLines
CartLine[] = DEFAULT_LINES
onLinesChange
(lines: CartLine[]) => void
freeShippingFrom
number = DEFAULT_FREE_SHIPPING_FROM
Subtotal from which shipping is free. Pass 0 to hide the meter.
loading
boolean = false
Replaces the lines with skeleton rows and holds the checkout action.
side
"right" | "left" = "right"
Edge the panel slides in from. Pass "left" in right-to-left layouts.
currency
string = "EUR"
locale
string = "en-US"
checkoutHref
string = "/checkout"
cartHref
string = "/cart"

Also accepts every prop of Omit< React.ComponentProps<"div">, "title" >.

Accessibility

Keyboard
Keyboard support for Mini Cart Side Drawer
KeyEffect
Enter or Space on the cart buttonOpens the drawer and moves focus inside it
Tab, Shift+TabCycles through close, then product link, decrease, increase and remove for each line, then checkout and view cart, without leaving the drawer
Enter or Space on Decrease or IncreaseChanges the quantity by 1. At a bound the button stays focusable and does nothing
Enter or Space on RemoveRemoves the line and moves focus to the line that takes its place, or to the empty state heading
EscapeCloses the drawer and returns focus to the cart button
Screen reader

Modal dialog named by its heading and described by the item count. Lines are a list, quantity is a named group of two labelled buttons, the subtotal sits in a status region and removal is announced.

  • Announces: {name} removed from cart.
  • Announces: Subtotal, {count} items {subtotal}
Reduced motion
Hazine adds colour transitions only, and the loading skeleton and spinner stay still. The slide and fade of the panel belong to the host sheet primitive and follow its settings.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies5

  • button
  • sheet
  • @hazine/heading
  • @hazine/use-controllable-state
  • lucide-react

Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.

Tokens shipped2

  • --success
  • --success-foreground

Added to your stylesheet in light and dark, unless you already define them.

Other takes on this3

The same question answered with a different structure.

  • mini carts

    Bottom sheet with two snap heights and the summary above the lines, so checkout is reachable at half height. Each drag (expand, collapse, dismiss) has a button equivalent.

    shadcn add @hazine/mini-cart-bottom-sheet

    Depends on button, drawer, @hazine/heading, @hazine/use-controllable-state, lucide-react

  • mini carts

    Trigger and panel are one surface that grows from pill to panel, with no overlay, backdrop or focus trap. It leaves the page while the cart is empty and takes an edge offset to clear page controls.

    shadcn add @hazine/mini-cart-floating-pill

    Depends on badge, button, @hazine/heading, @hazine/use-controllable-state, lucide-react

  • mini carts

    Non-modal popover on its trigger with no editing: only the newest lines are listed, older ones fold into one summed row that links to the cart, and the page behind stays usable.

    shadcn add @hazine/mini-cart-header-popover

    Depends on badge, button, popover, @hazine/heading, lucide-react

More in Carts and Checkout