Skip to content
Hazine

Mini Cart Header Popover

Pro

Read-only cart preview anchored to the header cart button: the three newest lines, the rest summed in one row, the subtotal and links to cart and checkout. Use it when a glance is enough.

How it differs. 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.

pnpm dlx shadcn@latest add @hazine/mini-cart-header-popover

Adds 1 file, 3 shadcn primitives (badge, button, popover), 1 Hazine item (@hazine/heading), and 1 package (lucide-react).

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": {
      "url": "https://api.hazine.dev/r/{name}.json",
      "headers": { "Authorization": "Bearer ${HAZINE_TOKEN}" }
    }
  }
}

Set HAZINE_TOKEN in your environment. The token comes with a Pro licence.

Props14

title
string = "Your cart"
headingLevel
HeadingLevel = 2
open
boolean
defaultOpen
boolean = false
onOpenChange
(open: boolean) => void
lines
CartLine[] = DEFAULT_LINES
Cart lines in the order they were added. The newest are shown first.
maxVisibleLines
number = 3
How many of the newest lines are listed before the rest is summed up.
loading
boolean = false
Replaces the lines with skeleton rows and holds the checkout action.
align
"start" | "center" | "end" = "end"
Edge of the cart button the panel lines up with.
currency
string = "EUR"
locale
string = "en-US"
checkoutHref
string = "/checkout"
cartHref
string = "/cart"
shopHref
string = "/products"
Where the empty state sends the shopper.

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

Accessibility

Keyboard
Keyboard support for Mini Cart Header Popover
KeyEffect
Enter or Space on the cart buttonOpens the popover and moves focus to its heading. Pressed again, closes it
Tab, Shift+TabMoves through the product links, the link to the earlier products, checkout and view cart, and wraps from the last link to the first and back. The page behind is not inert, so the pointer and a screen reader's reading cursor can still reach it
Shift+Tab on the headingMoves focus back to the cart button and leaves the popover open
Enter on a linkFollows it to the product, the cart or checkout
EscapeCloses the popover and returns focus to the cart button
Screen reader

Non-modal dialog named by its heading and described by the item count, opened from a button that carries aria-expanded and the item count in its name. Lines are a list and the subtotal sits in a status region.

  • Announces: Subtotal, {count} items {subtotal}
Reduced motion
The panel opens and closes without the popover primitive's fade, zoom and slide. The loading skeleton and spinner stay still.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies5

  • badge
  • button
  • popover
  • @hazine/heading
  • lucide-react

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

Tokens shipped0

None. The item is styled by the tokens your theme already has.

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

    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.

    shadcn add @hazine/mini-cart-side-drawer

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

More in Carts and Checkout