Skip to content
Hazine

Cart Page with Selective Checkout

Pro

Cart where every line has a checkbox and only the selected lines go to checkout, with a select-all control and bulk save or remove. Use for large baskets that shoppers buy in parts.

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

pnpm dlx shadcn@latest add @hazine/cart-page-selective-checkout

Adds 2 files, 1 shadcn primitive (button), 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.

Props11

title
string = "Your cart"
headingLevel
HeadingLevel = 2
lines
CartLine[]
defaultLines
CartLine[] = DEFAULT_LINES
onLinesChange
(lines: CartLine[]) => void
shipping
CartShipping = DEFAULT_SHIPPING
selectionNote
string = "Select what you want now. Unselected lines stay here for a later order."
Shown after the line count in the intro sentence.
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 with Selective Checkout
KeyEffect
TabMoves through Undo while it is shown, select all, the bulk toolbar as one stop, then checkbox, product link, quantity field and remove for each line, then checkout and the saved lines. The quantity step buttons are skipped
Space on a line checkboxAdds the line to this order or takes it out
Space on Select allSelects every line, or clears the selection when every line is already selected
Arrow Left, Arrow RightMoves between Save for later and Remove inside the toolbar, wrapping at the ends
Home, EndMoves to the first or last toolbar action
Enter or Space on a toolbar actionSaves or removes the selected lines and moves focus to Select all, or to the empty state heading
Arrow Up, Arrow Down on a quantityChanges the quantity by 1 and stops at 1 and at the line maximum. Page Up and Page Down change it by 10, Home and End set the lowest or highest allowed
Enter or Tab on a quantityCommits a typed quantity. 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 UndoRestores the lines as they were before the last save or removal
Enter or Space on Move to cartReturns a saved line to the cart, unselected, and moves focus to it
Screen reader

Native checkboxes drawn as discs inside a labelled group: one per line named after its product, and a select-all that reports mixed when some lines are selected. Bulk actions sit in a toolbar with one tab stop. Quantity is the Hazine spinbutton. Totals and action results use two separate polite status regions.

  • Announces: Total for {selected} of {count} lines, {total}, {subtotal} items + {shipping} shipping
  • Announces: {name} removed from cart.
  • Announces: {count} lines removed from cart.
  • Announces: {count} lines saved for later.
  • Announces: {name} moved to cart.
  • Announces: Change undone.
Reduced motion
No motion. Colour transitions only.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies5

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

    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

  • 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