Skip to content
Hazine

Cart Page as a Table

Pro

Cart rendered as a real table with columns for product, unit price, quantity, line total and remove, and totals in the table footer. Use when shoppers compare prices across many lines.

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

pnpm dlx shadcn@latest add @hazine/cart-page-table-layout

Adds 2 files, 2 shadcn primitives (button, table), 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": {
      "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.

Props13

title
string = "Your cart"
headingLevel
HeadingLevel = 2
lines
CartLine[]
defaultLines
CartLine[] = DEFAULT_LINES
onLinesChange
(lines: CartLine[]) => void
shipping
CartShipping = DEFAULT_SHIPPING
deliveryNote
string = "Ships from Utrecht in 2 working days."
Shown after the item count in the intro sentence.
loading
boolean = false
Locks every control while the consumer saves a change.
error
string
What went wrong and what to do next. Rendered in an alert.
currency
string = "EUR"
locale
string = "en-US"
checkoutHref
string = "/checkout"
continueHref
string = "/"

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

Accessibility

Keyboard
Keyboard support for Cart Page as a Table
KeyEffect
TabMoves through continue shopping, then product link, quantity and remove for each row, then checkout
Arrow Up, Arrow DownChanges the focused quantity by 1, starting from a typed number when there is one
Page Up, Page DownChanges the focused quantity by 10, stopping at 1 and at the order limit
Home, EndSets the focused quantity to 1 or to the order limit, when one is defined
DigitsTypes a quantity. A number outside 1 and the order limit is brought back inside when it is committed
EnterCommits a typed quantity, held between 1 and the order limit. Leaving the field does the same
EscapeDiscards a typed quantity
Enter or Space on RemoveRemoves the row and moves focus to the row header that takes its place, or to the empty state heading
Screen reader

Native table with a caption, column and row headers and totals in the footer. Lines are table rows, not list items. Quantity is a text input with role spinbutton. Removal, saving and the new total are announced in a separate status region.

  • Announces: {name} removed from cart.
  • Announces: Total {total} for {count} items.
  • Announces: Updating cart.
Reduced motion
The loading spinner stays still. Colour transitions only.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies6

  • button
  • table
  • @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

    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.

    shadcn add @hazine/cart-page-summary-rail

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

More in Carts and Checkout