Skip to main content

Mini cart

The mini cart drawer: lines with steppers, a discount badge and the subtotal

Cart Count is the header button with the item count; Mini Cart is the drawer it opens.

The count never travels in the HTML, so it is safe behind a page cache, and the drawer fetches its contents each time it opens for the same reason.

The drawer is built on a native <dialog>: focus is trapped, Escape closes it, and focus returns to the button that opened it.

Its options​

The Mini Cart properties panel

The header button and the drawer it opens are two components. These are the drawer's, Mini Cart; the button has a page of its own.

Props

PropTypeDefaultWhat it does
Show while editingon / offonOnly affects Etch's canvas, never the site. A closed drawer is display:none, so it would be invisible and unselectable while you build the page; with this on it is drawn where it really appears — pinned to the edge, full height, real width. Turn it off once it looks right and it stops covering the page you are editing.
Quantity stepper in each lineon / offonLets shoppers change how many of each product they want without leaving the drawer. The shop still decides the limits: the stepper stops at the stock, and a product sold one at a time never gets one.
Open when a product is addedon / offoffShows the drawer by itself after an add to cart, as confirmation. It takes focus and covers the page, so leave it off on a shop where people add several things in a row — the cart counter already updates on its own.
TitletextYour cart
Close button labeltextClose
View cart labeltextView cart
Checkout labeltextCheckout
Subtotal labeltextSubtotal
Undo labeltextUndo
Colors → Backgroundtextvar(--fe-woo-surface, #ffffff)
Colors → Texttextvar(--fe-woo-color, #111827)
Colors → Accenttextvar(--fe-woo-accent, #1f2937)Used for the checkout button.
Colors → Button texttextvar(--fe-woo-accent-color, #ffffff)
Colors → Buttons on hovertextvar(--fe-woo-accent-hover, color-mix(in srgb, var(--fe-woo-mc-accent, #1f2937) 85%, var(--fe-woo-mc-accent-color, #ffffff)))
Colors → Button text on hovertextvar(--fe-woo-accent-color-hover, var(--fe-woo-mc-accent-color, #ffffff))
Size → Drawer widthtext24rem

Variables of its own

VariableDefaultWhat it controls
--fe-woo-mc-width24remHow wide the drawer is.
--fe-woo-mc-bgvar(--fe-woo-surface, #ffffff)Its background.
--fe-woo-mc-backdroprgb(17 24 39 / 45%)What darkens the page behind it.
--fe-woo-mc-badge-bgvar(--fe-woo-accent, #111d2e)The badge on the header button.
--fe-woo-mc-badge-colorvar(--fe-woo-accent-color, #ffffff)Its number.
--fe-woo-mc-remove#6b7280The × on each line.
--fe-woo-mc-remove-active-color#ffffffThat × once it is pressed.
--fe-woo-mc-dangervar(--fe-woo-danger, #b91c1c)A line that can no longer be bought.
--fe-woo-mc-sale-bg#fee2e2The badge on a discounted line.
--fe-woo-mc-sale-color#b91c1cIts text.
--fe-woo-mc-progress#0f766eThe bar of a free-shipping goal.
--fe-woo-mc-trackvar(--fe-woo-border, #e5e7eb)The unfilled part of that bar.
--fe-woo-mc-image-size4.5remThe product photo on each line.
--fe-woo-mc-enter0.32sHow long the drawer takes to slide in.
--fe-woo-mc-leave0.2sAnd to slide out — shorter on purpose, because a dismissal that lingers feels slow.