Skip to content
Hazine

Cart Page with Summary Rail

Full cart page with editable lines beside a pinned order summary rail holding the delivery estimate, promo entry, itemised totals and the checkout action. The default cart for desktop-first stores.

How it differs. Lines and rail share one frame and the rail stays pinned while lines scroll. Under 48rem the rail drops below and the total with checkout becomes a sticky bottom bar. Removed lines leave an undo row.

pnpm dlx shadcn@latest add @hazine/cart-page-summary-rail

Adds 3 files, 3 shadcn primitives (button, input, label), 3 Hazine items (@hazine/heading, @hazine/number-input-stepper-buttons, @hazine/use-controllable-state), and 1 package (lucide-react).

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
lines
CartLine[]
defaultLines
CartLine[] = DEFAULT_LINES
onLinesChange
(lines: CartLine[]) => void
promos
CartPromo[] = DEFAULT_PROMOS
Codes the cart accepts. A submitted code outside this list shows as invalid.
promoCode
string | null
The applied code, or null for none.
defaultPromoCode
string | null = null
onPromoCodeChange
(code: string | null) => void
shipping
CartShipping = DEFAULT_SHIPPING
delivery
CartDelivery = DEFAULT_DELIVERY
currency
string = "EUR"
locale
string = "en-US"
checkoutHref
string = "/checkout"
continueHref
string = "/"

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

Accessibility

Pattern
Cart structure, Form with labelled fields, Landmarks and headings, Spinbutton (APG, opens in a new tab)
Keyboard
Keyboard support for Cart Page with Summary Rail
KeyEffect
TabMoves through product link, quantity and remove for each line, the undo button of a removed line, then promo code, apply, remove code and checkout
Arrow Up, Arrow DownChanges the focused quantity by 1, stopping at 1 and at the line limit. Page Up and Page Down change it by 10, Home and End set 1 or the limit
EnterCommits a typed quantity. Leaving the field does the same and Escape discards it
Enter or Space on RemoveRemoves the line and moves focus to the line that takes its place, or to the empty state heading
Enter or Space on UndoPuts the removed line back in its position and moves focus to it
Enter in the promo fieldApplies the code. An unknown code marks the field invalid, keeps focus in it and leaves an applied code in place
Screen reader

Section labelled by its heading. Lines are a list, quantity is a spinbutton named after the product, totals are a description list, and one polite status region speaks each change together with the new total.

  • Announces: {name}, quantity {quantity}. Total {total} for {count}.
  • Announces: {name}, quantity {quantity}, the limit per order. Total {total} for {count}.
  • Announces: {name} removed from cart. Undo is available. Total {total} for {count}.
  • Announces: {name} is back in your cart. Total {total} for {count}.
  • Announces: Code {code} applied, {label}. Total {total} for {count}.
  • Announces: Code {code} is not active. Total {total} for {count}.
  • Announces: Code {code} is not active. {applied} stays applied. Total {total} for {count}.
  • Announces: Code {code} removed. Total {total} for {count}.
Reduced motion
No motion. Colour transitions only.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies7

  • button
  • input
  • label
  • @hazine/heading
  • @hazine/number-input-stepper-buttons
  • @hazine/use-controllable-state
  • 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 this5

The same question answered with a different structure.

  • cart pages

    One frame per shipment, split into its lines and its own delivery and cost rail with checkout and remove all. A closing ledger sums shipments as rows. A removed shipment leaves a restore slot.

    shadcn add @hazine/cart-page-grouped-by-shipment

    Depends on button, @hazine/heading, @hazine/number-input-stepper-buttons, @hazine/use-controllable-state, lucide-react

  • cart pages

    Two lists with moves in both directions: cart lines closed by a totals band, then a hairline grid of saved lines. Focus stays in the source list and one status message gives count and total.

    shadcn add @hazine/cart-page-saved-for-later

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

  • cart pages

    Selection drives everything: total, item count and checkout label follow the selected lines, a bulk toolbar replaces the hint while any line is selected, and the rail says what stays behind.

    shadcn add @hazine/cart-page-selective-checkout

    Depends on button, @hazine/heading, @hazine/number-input-stepper-buttons, @hazine/use-controllable-state, lucide-react

  • cart pages

    One column with no rail: each line keeps its controls under its name, totals follow the last line as a receipt, and checkout sits inline at the end with no competing region.

    shadcn add @hazine/cart-page-single-column

    Depends on button, separator, @hazine/heading, @hazine/number-input-stepper-buttons, @hazine/use-controllable-state, lucide-react

  • cart pages

    Semantic table whose footer totals sit under the line total column. Below 48rem each row reflows to a stack of label and value pairs with the column labels as visible text.

    shadcn add @hazine/cart-page-table-layout

    Depends on button, table, @hazine/heading, @hazine/number-input-stepper-buttons, @hazine/use-controllable-state, lucide-react

More in Carts and Checkout