defuss-shadcn / Website / Shop / order-summary
Built with: CSS
Order SummaryBLK
Displays an order's items and charge breakdown - pictures with quantity badges, the lines, discount, shipping and total; collapsible on small screens. Part of the Shop blocks.
On this page (3)
§Default
The items with a quantity badge on each thumbnail, then the breakdown (<dl>): subtotal, discount, shipping and the total with VAT.
§Collapsible
data-variant='collapsible' on a <details>: on a small screen the summary shows only "Show order summary" and the total; it opens natively.
§CSS view file
/* -- Order Summary (website · Shop) --------------------------------------- Displays an order's items and charge breakdown - pictures with quantity badges, the lines, discount, shipping and total; collapsible on small screens. */@layer components { /* every box in the block measures border-box - the same on any page */ :where(.mk-order-summary, .mk-order-summary *, .mk-order-summary ::before, .mk-order-summary ::after) { box-sizing: border-box; } .mk-order-summary { display: grid; gap: 1.25rem; padding: 1.5rem; border-radius: var(--radius-xl); background: var(--muted); max-width: 26rem; } .mk-order-summary-title { margin: 0; font-size: 1rem; font-weight: 600; } .mk-order-summary-items { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; & li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.875rem; } } .mk-order-summary-thumb { position: relative; & img { display: block; width: 3.5rem; aspect-ratio: 4 / 5; object-fit: cover; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); } & b { position: absolute; top: -0.5rem; right: -0.5rem; display: grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding-inline: 0.25rem; border-radius: 999px; background: var(--muted-foreground); color: var(--background); font-size: 0.6875rem; font-weight: 700; box-sizing: border-box; } } .mk-order-summary-name { display: grid; font-size: 0.875rem; font-weight: 600; & small { color: var(--muted-foreground); font-size: 0.8125rem; font-weight: 400; } } .mk-order-summary-price { font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; } .mk-order-summary-totals { display: grid; gap: 0.5rem; margin: 0; padding-block-start: 1rem; border-block-start: 1px solid var(--border); & div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.875rem; } & dt { color: var(--muted-foreground); } & dd { margin: 0; font-variant-numeric: tabular-nums; } & [data-discount] dd { color: #15803d; } & [data-total] { align-items: baseline; margin-block-start: 0.5rem; padding-block-start: 0.875rem; border-block-start: 1px solid var(--border); } & [data-total] dt { color: var(--foreground); font-size: 1rem; font-weight: 600; } & [data-total] small { display: block; color: var(--muted-foreground); font-size: 0.75rem; font-weight: 400; } & [data-total] dd { font-size: 1.375rem; font-weight: 700; } } .mk-order-summary[data-variant="collapsible"] { gap: 0; padding: 0; & > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; cursor: pointer; list-style: none; color: var(--primary); font-size: 0.9375rem; font-weight: 600; } & > summary::-webkit-details-marker { display: none; } & > summary span { display: inline-flex; align-items: center; gap: 0.375rem; } & > summary svg { width: 1rem; height: 1rem; transition: rotate 200ms ease; } &[open] > summary svg { rotate: 180deg; } & > summary b { color: var(--foreground); font-size: 1.125rem; font-variant-numeric: tabular-nums; } & > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: var(--radius-xl); } & > div { display: grid; gap: 1.25rem; padding: 0 1.25rem 1.25rem; } } /* -- Accessibility ------------------------------------------- */ @media (prefers-reduced-motion: reduce) { .mk-order-summary[data-variant="collapsible"] > summary svg { transition: none; } } @media (forced-colors: active) { .mk-order-summary { border: 1px solid CanvasText; } }}Comments, ideas or improvements? Edit this page's source on GitHub