Skip to main content
Copy for LLM

Cart List

A cart is a list, and saying so out loud is most of this component's job.

<x-wirekit::cart-list> is the list; <x-wirekit::cart-item> is one line in it. The line composes pieces you already know — image, price, number-input and button — so nothing here behaves differently from the way it behaves everywhere else.

A cart with three lines
  • Brass desk lamp Warm white · Dimmable Previous price €59.00 €39.00

    Remove Brass desk lamp?

    €39.00
  • Walnut notebook A5 · Dotted €12.00

    Remove Walnut notebook?

    €24.00
  • Merino crew Charcoal · M €89.00

    Remove Merino crew?

    €89.00

Why the list is a component

A <ul> you style yourself is one line of markup, and it misses five things you would not think to write. The list carries them:

  • role="list". Removing the bullet markers removes the list semantics in WebKit — so a cart styled with list-none is announced as a run of text on every iPhone, and the page looks completely normal while it happens. The explicit role puts the semantics back.
  • A name. A checkout page usually holds more than one list. Without a name each is announced as "list, 3 items" and they cannot be told apart.
  • The separator. The list draws a rule between lines and none after the last one, in one place and at the theme's border width, so a line you write needs no border of its own and no :last-child rule to leave it off at the end.
  • A prose reset. Carts are often rendered inside prose-styled containers, which add list indentation and markers back.
  • Shared columns. The lines take the list's columns, so their quantities stand above each other and their totals end on one edge, as in a table, whatever each line holds. The remove control stands left of the quantity, beside the −, where it draws the eye less than at the end of the line, and a quantity that is only text ends on its column's edge. A line without a remove control or without actions leaves that cell empty and keeps the column. In a list narrower than 32rem the name takes a row of its own, with the picture before it, a line's actions the row under it, and the remove control, the quantity and the total the row under them, still in their columns. Below 20rem, as on a phone of 320px, the total stands at the end of the name's row and the remove control and the quantity take the row under it, so the name keeps the width of the line but the total's, and in a compact line the line's actions stand at the end of the row under the name. A stepper with a long unit after its + and a wide remove slot can still be wider than a list that narrow. The columns need subgrid, which Chrome and Edge have from 117 and every supported Safari and Firefox has; an older Chromium sets each line on a row of its own, with every control in the same order.

The totals are the application's

cart-item never multiplies quantity by price. You pass line-total, and you pass a new one when the quantity changes.

That is deliberate. A component that computed the total would own cart state — and cart state is where tax rules, tiered pricing, bundle discounts and currency rounding live, none of which belong in a UI library. Every application that got a computed total would then have to take it back out.

Sales

Pass compare-at and the previous price is struck through, exactly as on product-card. The strike only appears when the compare-at price is genuinely higher — passing a lower one draws a discount that does not exist, so it is ignored.

A line on sale
  • Brass desk lamp Previous price €59.00 €39.00

    Remove Brass desk lamp?

    €39.00

Quantity

The stepper is number-input. min defaults to 1, because a cart line holding none of something is a removal rather than a quantity. Pass max when you know the stock ceiling, and unit when the thing is not counted in pieces.

Bind the quantity by writing the binding on the line, wire:model in any of its forms, such as wire:model.live or wire:model.blur, or x-model. It goes to the stepper and to nothing else.

A cart that works without script sends its quantities with a form. quantity-name names the field of a line, so the form sends each quantity under a name your application can match to the line. Without it the field carries no name and a form sends nothing for it.

<form method="POST" action="/cart">
    @csrf
    <x-wirekit::cart-list label="Your cart">
        <x-wirekit::cart-item id="sku-1" name="Linen shirt" :price="4900" :minor-units="true" :quantity="2" quantity-name="lines[sku-1][quantity]" />
        <x-wirekit::cart-item id="sku-2" name="Wool socks" :price="1200" :minor-units="true" :quantity="1" quantity-name="lines[sku-2][quantity]" />
    </x-wirekit::cart-list>
    <x-wirekit::button type="submit">Update cart</x-wirekit::button>
</form>
Stock ceiling and a unit suffix
  • Merino crew €89.00

    Remove Merino crew?

    €267.00
  • Loose-leaf tea €14.50

    Remove Loose-leaf tea?

    kg
    €29.00

The stepper renders at size="lg" rather than the usual md, and that is measured rather than chosen by eye. --size-wk-md clears WCAG 2.2 SC 2.5.8 (24px, level AA) but misses the 44px of SC 2.5.5 (level AAA) and of platform touch guidance; --size-wk-lg clears both. Raising the token instead would move every component that reads it for one ecommerce case, so the size lives on this component and you can still override it per line.

Removing a line

Every line ships a remove control unless you pass :removable="false". Before it takes the line out it asks, "Remove Linen shirt?", with "Remove" and "Cancel", and only "Remove" dispatches wirekit:cart-remove: a browser event carrying the line's key, so a Livewire component can listen for it without this library knowing anything about your cart. At its smallest quantity a line's − does the same: one less of the last piece is a removal, so − draws the remove glyph there and asks the same question. A listener around the list hears the removal from either. :remove-at-min="false" keeps − disabled at the minimum instead, and :confirm-remove="false" takes the line out without asking, from both, for a till that answers every press at once.

<div x-on:wirekit:cart-remove="$wire.remove($event.detail.item)">
    <x-wirekit::cart-list>
        @foreach ($lines as $line)
            <x-wirekit::cart-item :id="$line->id" :name="$line->name" :price="$line->price" :line-total="$line->total" />
        @endforeach
    </x-wirekit::cart-list>
</div>

Once your render has taken the line out, the focus goes on to the next control after it, or to the last one before it when the line was the last, so a reader on the keyboard stays where they were instead of starting again at the top of the page. A line your listener keeps, a removal it refused, keeps the focus as well.

Give each line an id. Without one the key is derived from the product name, which is stable enough for a demo and wrong the moment two lines share a name — the same shirt in two sizes is the ordinary case, not the edge case.

The events carry that key as it is. The row also uses it as its HTML id, and when a second cart on the page shows the same line, a mini cart beside the cart page, that row's id gets -2 after it, so the two rows never share one.

An action beside removal, such as "Save for later", goes in the actions slot, left of the quantity. Replace the remove control itself with the remove slot when taking a line out works differently in your cart, such as an undo row.

A line that cannot be removed, and one with an action of its own
  • Gift wrapping €5.00
    €5.00
  • Merino crew €89.00

    Remove Merino crew?

    €89.00

In a cart, the name of a line is where a reader goes back to the product. href makes the name that link, in either layout, and nameLang gives a name in another language its own:

<x-wirekit::cart-list label="Cart">
    <x-wirekit::cart-item
        name="Bergkäse"
        href="/products/bergkaese"
        name-lang="de"
        :price="1290"
        :minor-units="true"
        currency="EUR"
        :line-total="1290"
    />
</x-wirekit::cart-list>

The name keeps its look and takes a link's underline on hover. The controls of the line still say the name, as in "Remove Bergkäse", so a list of remove buttons stays apart for voice control.

Wiring It to Livewire

The cart lives in your Livewire component: the lines, their quantities and what to do on a removal. The component below keeps the lines in an array keyed by something stable, with the prices in cents:

<?php

namespace App\Livewire;

use Livewire\Component;

class Cart extends Component
{
    // 1. One entry per line. The key identifies the line when it is removed.
    public array $lines = [
        'lamp-warm-white' => ['name' => 'Brass desk lamp', 'price' => 3900, 'quantity' => 1],
        'notebook-a5' => ['name' => 'Walnut notebook', 'price' => 1200, 'quantity' => 2],
    ];

    // 2. The remove control sends the line's key; taking the line out is all there is to do.
    public function remove(string $item): void
    {
        unset($this->lines[$item]);
    }
}

The view binds each quantity and computes each line total, so a changed quantity renders a new total on the next request:

{{-- resources/views/livewire/cart.blade.php --}}

{{-- 1. One listener around the list hears the remove control of every line. --}}
<div x-on:wirekit:cart-remove="$wire.remove($event.detail.item)">
    <x-wirekit::cart-list>
        @foreach ($lines as $key => $line)
            {{-- 2. `id` is the key the remove control sends; `wire:model` reaches the stepper. --}}
            <x-wirekit::cart-item
                wire:key="{{ $key }}"
                :id="$key"
                wire:model.live="lines.{{ $key }}.quantity"
                :name="$line['name']"
                :price="$line['price']"
                :minor-units="true"
                currency="EUR"
                :quantity="(int) $line['quantity']"
                :line-total="$line['price'] * (int) $line['quantity']"
            />
        @endforeach
    </x-wirekit::cart-list>
</div>

A field someone empties sends an empty string, and (int) reads it as 0, so the line costs nothing until a quantity is typed. Validate the quantity in your component when an order is placed from it; the stepper's min and max guide a person but do not stop a request.

A line that is only shown

A cart someone looks at but does not change, such as the customer-facing screen of a till or an order confirmation, takes readonly. The quantity reads as text with its unit, in a light gray box as large as the quantity of a stepper, and the built-in remove control goes: a stepper on a screen nobody touches looks operable and does nothing. A remove slot you pass still renders. In a cart list the quantities end on one edge, so a count and a weight with its unit stand above each other.

Where another device shows the quantity, such as the weight on a scale beside the till, add hide-quantity and the line leaves it out, the visually hidden word "Quantity" with it: a "1" beside a weighed article would read as one piece or one kilogram.

Two more things belong on such a line. unitPrice and unitMeasure add the unit price a packaged or measured article has to show beside its price, and the details slot takes further lines about the line, such as what it saves or the promotion it is part of.

A cart that is only shown
  • Olive oil, 500 ml Previous price €7.99 €7.49 (€14.98 / 1 l)
    You save €1.00 · Spring offer
    Quantity 2 €14.98
  • Coffee beans €15.98
    Quantity 0.532 kg €8.50

In a list where some articles have a picture and some do not, a line without one takes the media slot, so its name starts where the others do. The slot wins over image and fills the same column, and there is no placeholder of the kit's own: a line with neither has no column. total-size sets the line total on the scale of price, from xs to xl, so a screen read from across a counter can show what a line costs above its name:

Lines with and without a picture, the total above the name
  • Desk lamp €49.00
    Quantity 1 €49.00
  • Gift wrapping €3.50
    Quantity 2 €7.00

A screen read from across a counter needs the whole type scale larger, not one component. Set --font-scale-wk on the page that shows it, <html style="--font-scale-wk: 1.75">, and every step of the scale grows with it, the prices and the cart summary included. Design tokens describes the factor.

A line for a till

A till lists its lines in a narrow column, and every press on − or + is something the till has to record. layout="compact" sets a line in two rows: the name on one line beside what the line costs, and under them what it is on the left and how many on the right. Where the unit price does not fit beside the quantity, the quantity and the line's controls move to a row of their own, which happens in a narrow column and on a touch screen, where the controls are larger; a long variant shortens instead. stepper="buttons" shows − and + with the quantity between them, and each press dispatches wirekit:cart-decrement or wirekit:cart-increment with the line's key. Nothing holds a press back while your component answers, so two quick presses are two presses, and the quantity shown is the one it renders next.

<div x-on:wirekit:cart-increment="$wire.increment($event.detail.item)"
     x-on:wirekit:cart-decrement="$wire.decrement($event.detail.item)">
    <x-wirekit::cart-list label="Till">
        @foreach ($lines as $line)
            <x-wirekit::cart-item :id="$line->id" layout="compact" stepper="buttons" :min="0" removes-at-zero remove-icon="trash"
                :name="$line->name" :price="$line->price" :quantity="$line->quantity" :line-total="$line->total" />
        @endforeach
    </x-wirekit::cart-list>
</div>

With :min="0" the − stays active on the last piece, and your component decides what that press means, such as taking the line out. When it does take the line out, say so with removes-at-zero: the − of the last piece then draws the remove control's glyph and is named "Remove Butter croissant" rather than "Decrease the quantity of Butter croissant", and it still dispatches wirekit:cart-decrement. remove-icon picks that glyph for the remove control as well, trash for a bin instead of the cross. Put a line's own actions, a discount or why a price applies, in the actions slot, left of the quantity, and give a button there the line's size, lg by default, so it is as large as the stepper and the remove control.

The quantity between − and + is a target as large as the buttons beside it, and on a touch screen all three, with the remove control beside them, are at least 44px, so a tap on the edge of one stays with it. Two taps on the quantity, or a double click, dispatch wirekit:cart-quantity with the line's key, so your till can open an entry of its own, a keypad, for a count that would take many presses; one tap does nothing. A screen reader activates with a single click and cannot make the double tap, so offer the same entry where the keyboard reaches it as well, as a line action:

<div x-on:wirekit:cart-quantity="$wire.openQuantity($event.detail.item)">
    <x-wirekit::cart-list label="Till">
        @foreach ($lines as $line)
            <x-wirekit::cart-item :id="$line->id" layout="compact" stepper="buttons"
                :name="$line->name" :price="$line->price" :quantity="$line->quantity" :line-total="$line->total">
                <x-slot:actions>
                    <x-wirekit::dropdown :label="'Actions for '.$line->name">
                        <x-slot:trigger>
                            <x-wirekit::button intent="neutral" surface="ghost" size="lg" icon-only>
                                <x-slot:iconLeft>
                                    <x-wirekit::icon name="more-vertical" size="sm" aria-hidden="true" />
                                </x-slot:iconLeft>
                                Actions for {{ $line->name }}
                            </x-wirekit::button>
                        </x-slot:trigger>
                        <x-wirekit::dropdown.item wire:click="openQuantity({{ $line->id }})">Enter the quantity</x-wirekit::dropdown.item>
                    </x-wirekit::dropdown>
                </x-slot:actions>
            </x-wirekit::cart-item>
        @endforeach
    </x-wirekit::cart-list>
</div>

A name or a variant too long for its line ends in an ellipsis, and while it is cut it shows its whole wording in a tooltip, on hover, on keyboard focus and on a tap.

Compact lines with a press stepper and line actions
  • Oat flat white, large
    €8.40
    Art. 1042 · Oat milk
    €4.20

    Remove Oat flat white, large?

    2
  • Butter croissant
    €2.90
    Art. 2210
    €2.90

    Remove Butter croissant?

    1

The − and + are outline buttons. Where every button of your interface carries a fill, stepper-surface gives them soft, filled or ghost instead, on one line or for every line in the configuration.

A press stepper with soft buttons
  • Oat flat white, large
    €8.40
    Art. 1042 · Oat milk
    €4.20

    Remove Oat flat white, large?

    2

A compact line gives its name up to two lines and cuts it after the second, cuts the line under it to one, and a tooltip shows the rest. On an overview the reader confirms an order on, the name and the variant belong there in full: :truncate="false" lets both wrap, and the line keeps its two rows.

A compact line that states its name in full
  • Merino wool crew neck sweater with long sleeves €89.00
    Charcoal gray · Size M · Organic merino from a certified farm €89.00
    Quantity 1

A total that fits its line

A line total in a narrow column, a large amount or one in a currency with many digits, can shrink to fit with fit-total, which takes what fit takes on price: fit-total alone for the --text-wk-fit-floor token, or a length such as fit-total="0.5rem" for a floor of its own. In the compact line the name keeps at least eight characters first, then the total shrinks down to its floor, and only below that does the name give up more, ending in an ellipsis. In the default line the total shrinks once its controls stand on a row of their own.

A compact line whose total fits beside the name
  • Espresso machine, dual boiler
    €12,495.00
    Art. 3310
    €2,499.00

    Remove Espresso machine, dual boiler?

Without separators

:divided="false" leaves the rule between the lines out, for a list that stands on a surface of its own, such as a mini cart in a popover, where the lines need no line between them.

Lines without a rule between them
  • Brass desk lamp €39.00

    Remove Brass desk lamp?

    €39.00
  • Walnut notebook €12.00

    Remove Walnut notebook?

    €24.00

Props

cart-list

Prop Type Default Description
label string Cart Accessible name for the list.
divided bool true Draw a separator between lines.
scope string|null null Theme scope.

cart-item

Prop Type Default Description
name string|null null Product name. Also what the remove control announces.
href string|null null Makes the name a link to its product, in either layout. The name keeps its look and takes a link's underline on hover; the controls of the line still say the name.
nameLang string|null null The language of the name, where it is not the page's. Set on the name alone, so a screen reader says the name in that language's voice and the rest of the line in the page's.
image string|null null Thumbnail URL.
imageAlt string '' Alt text. Empty on purpose — the name is already in the row as text.
price int|float|null null Unit price. An empty string counts as null.
compareAt int|float|null null Previous price, struck through when it is higher.
maxPrecision int|null null The most decimals for the unit price and the previous price, for a piece that costs less than the currency's smallest unit, such as 0.045 €. The line total is an amount and keeps the currency's digits. See price.
currency string config Currency code.
minorUnits bool false Treat the amounts as minor units (cents).
locale string|null null Locale the amounts and the quantity are written in. Unset, the application's locale. Give the line and the cart summary the same one, so a display reads alike from the lines to the total.
lineTotal int|float|null null What the line costs at this quantity. You compute it. An empty string counts as null.
quantity int|float 1 Current quantity. A readonly line also shows a measured one, such as 0.532 with unit="kg".
min int 1 Lowest quantity.
max int|null null Stock ceiling.
step int 1 Stepper increment.
size sm|md|lg lg Stepper size.
unit string|null null Unit suffix for the stepper.
quantityName string|null null The name a form sends the quantity under, for a cart without script, such as lines[42][quantity]. Without it the field carries no name. A line with stepper="buttons" or readonly has no field to name.
removable bool true Render the built-in remove control.
removeIcon string close The icon alias the built-in remove control draws, such as trash for a bin. A − that takes the line out (removesAtZero) draws it too.
readonly bool false Show the line without operating it: the quantity as text with its unit, no built-in remove control.
hideQuantity bool false Leave the quantity of a readonly line out, visibly and for a screen reader. An editable line keeps its field.
unitPrice int|float|null null Unit price by a reference measure, shown beside the price. Needs unitMeasure.
unitMeasure string|null null The reference for unitPrice, such as kg or 1 l.
layout default|compact default compact sets the line in two rows for a narrow column: the name beside the line total, then the variant and unit price beside the quantity.
truncate bool true Whether compact cuts the name and the line under it to one line each, with the rest in a tooltip. false lets both wrap, for an overview the reader confirms an order on. The default layout wraps either way. The default comes from truncate in the cart-item entry of the configuration.
stepper field|buttons field buttons shows − and + around the quantity, and each press dispatches wirekit:cart-decrement or wirekit:cart-increment with the line's key; two taps on the quantity dispatch wirekit:cart-quantity. field is the number field a wire:model binds.
stepperSurface outline|soft|filled|ghost outline The surface of the − and + of stepper="buttons", as on a button. outlined is accepted as an alias of outline. The default comes from stepper-surface in the configuration.
removesAtZero bool false Your application takes the line out when its quantity reaches zero. With stepper="buttons" and :min="0", the − of the last piece draws the remove glyph and is named "Remove …", and it still dispatches wirekit:cart-decrement.
removeAtMin bool true At the smallest quantity, − stays in use, draws the remove glyph and takes the line out as the remove control does, after the same question unless confirmRemove is off. Off, − is disabled there. A line that cannot be removed, is only shown or brings a remove slot keeps − disabled, and the press stepper of a line that leaves at zero keeps to removesAtZero. The default comes from remove-at-min in the configuration.
confirmRemove bool true Whether taking the line out asks first, "Remove …?" with "Remove" and "Cancel", from the remove control and from − at the smallest quantity. Off, both dispatch wirekit:cart-remove at once. The default comes from confirm-remove in the configuration.
totalSize xs|sm|md|lg|xl|null null The size of the line total, on the scale of price. Without it the total takes the size price is configured with.
fitTotal bool|string|null null Shrinks the line total down to a floor so it fits its line, as fit on price: true for the --text-wk-fit-floor token, or a length. In the compact line the name keeps eight characters before the total shrinks. See A total that fits its line.
scope string|null null Theme scope.

Slots

Slot Component Description
default cart-list The lines.
default cart-item A meta line under the name — variant, size, delivery note.
remove cart-item Replaces the built-in remove control entirely.
actions cart-item A line's own actions, left of the quantity, such as a menu or "Save for later".
details cart-item Further lines under the unit price, such as the saving or a promotion.
media cart-item The thumbnail column's content in place of image, such as a painted placeholder for an article without a photo, so the names of a list start in one column. Hide a purely decorative placeholder from assistive technology; the name already says what the line is.

Accessibility

  • The list is a real <ul> with an explicit role="list" and a name, so it survives the marker removal that otherwise costs it its semantics in WebKit.
  • The remove control names its product — "Remove Merino crew", not "Remove". Ten controls that all announce the same word cannot be told apart by anyone using voice control, and they read as ten identical buttons in a screen-reader element list.
  • Taking a line out asks first, in an alert dialog that names the line, "Remove Merino crew?". Focus starts on "Cancel", so a plain Enter keeps the line, and Escape closes the question without taking it out.
  • The line total sits in a polite live region, so a quantity change is announced once the new total arrives rather than silently. With stepper="buttons" the quantity is the region instead: a press moves both, and the reader pressed for the quantity.
  • The − and + of stepper="buttons" name their product, "Decrease the quantity of Butter croissant", for the reason the remove control does, and sit in a group named "Quantity of Butter croissant". The number field of the default stepper carries the same name, and its − and + say which line they change in the same words: the line hands them to the number input as decreaseLabel and increaseLabel.
  • The − and + of stepper="buttons" and the remove control show their name in a tooltip on hover and on keyboard focus, since each carries a glyph and no word. The tooltip repeats the name rather than describing the button, so a screen reader reads it once.
  • The unit price forwards to price, which already renders the struck previous price with a screen-reader-only label. This component does not re-solve that.
  • The stepper is a native <input type="number">. It carries no aria-valuenow: that property belongs to role="spinbutton", and adding it to a native number field overrides the value the browser already exposes with a second copy that can disagree.
  • With readonly the quantity is text, and the word the stepper's label carried, "Quantity", names it for a screen reader in a visually hidden prefix.
  • In a compact line a name or a variant that is cut shows its whole wording in a tooltip while it is cut, and takes a tab stop of its own, so the keyboard reaches the tooltip as well. A screen reader reads the whole text either way.
  • The quantity between the − and + of stepper="buttons" is a target as large as the buttons. Its double tap is a shortcut a screen reader cannot make, so whatever it opens needs a second way in that the keyboard reaches.

Keyboard Interaction

Key Action
Tab Move to the quantity field, then to the remove control, then to the next line. In a compact line a name or a variant that is cut takes a tab stop first and shows its whole wording.
↑ / ↓ Increment / decrement the quantity, when the field has focus.
Enter / Space Activate the remove control, which asks whether the line goes unless confirmRemove is off.
Escape Close that question and keep the line.

The list itself takes no focus and has no keyboard model of its own — it is a container, and every control inside it is reached in document order.

Customization

Set a project-wide floor for the quantity, a different stepper size, the surface of the press stepper's buttons, whether a compact line cuts its name, whether − at the smallest quantity takes the line out, or whether taking a line out asks first. php artisan wirekit:install published config/wirekit.php, and the cart-item entry is already in its components array; change it there:

// config/wirekit.php
'components' => [
    'cart-item' => ['min' => 1, 'size' => 'lg', 'stepper-surface' => 'outline', 'truncate' => true, 'remove-at-min' => true, 'confirm-remove' => true],
],

min is the lowest quantity a line can reach before the decrement stops. Leaving it at 1 is usually right — a line holding none of something is a removal, not a quantity — but a shop selling by weight or in pairs may want its own floor.

size is the stepper's touch target. The default is lg rather than the md used elsewhere, which is the point made above: md clears the AA target size and misses the AAA one, and lg clears both. Lower it only where you know the surface is not touched.

stepper-surface is the surface of the − and + of stepper="buttons": outline, soft, filled or ghost.

truncate is whether layout="compact" cuts the name and the line under it to one line each (true) or lets them wrap (false), for every line that does not say otherwise.

remove-at-min is whether − at the smallest quantity takes the line out (true) or stays disabled there (false).

confirm-remove is whether taking a line out asks first (true) or happens at once (false), from the remove control and from − at the smallest quantity.

Further Reading

  • product-card — the grid the cart is filled from
  • price — currency formatting, compare-at, minor units
  • number-input — the stepper, its bounds and its suffix

Updated in WireKit v2.75.0 (2026-12-01)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store