Theme
On this page (3)
Component Skill — components/wishlist-item/component-skill.md

Native basis

An <li>: thumbnail, name link, options, stock (data-stock="in|low|out"), the saved date, the price and actions - Add to cart (or "Notify me" when out of stock) and a labelled remove button.

Built from

Button.

Web Platform APIs

<time>Container queries:has()

Classes

.mk-wishlist-list.mk-wishlist-item.mk-wishlist-item-image.mk-wishlist-item-info.mk-wishlist-item-name.mk-wishlist-item-options.mk-wishlist-item-added.mk-wishlist-item-stock.mk-wishlist-item-price.mk-wishlist-item-actions.mk-wishlist-item-remove

Data attributes

data-stock: in, low, out; data-variant="card".

§List

Rows: picture, name link, options, stock as text with a colored dot (data-stock in / low / out - out fades the picture and offers "Notify me"), the saved date, price and labelled actions.

§Cards

data-variant='card': the same items as cards in a grid.

§CSS view file

/* -- Wishlist Item (website · Shop) ---------------------------------------
   Displays one saved product with purchase and removal actions - stock status, price, when it was saved, add to cart or get notified. */
@layer components {
  /* every box in the block measures border-box - the same on any page */
  :where(.mk-wishlist-item, .mk-wishlist-item *, .mk-wishlist-item ::before, .mk-wishlist-item ::after) { box-sizing: border-box; }
  .mk-wishlist-list { display: grid; margin: 0; padding: 0; list-style: none; border-block-start: 1px solid var(--border); }
  .mk-wishlist-item {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.5rem 1.25rem;
    padding-block: 1.25rem;
    border-block-end: 1px solid var(--border);
  }
  .mk-wishlist-item-image { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius-md); background: var(--muted); }
  .mk-wishlist-item:has([data-stock="out"]) .mk-wishlist-item-image { opacity: 0.5; filter: grayscale(1); }
  .mk-wishlist-item-info { display: grid; gap: 0.125rem; min-width: 0; }
  .mk-wishlist-item-name { margin: 0; font-size: 0.9375rem; font-weight: 600;
    & a { color: inherit; text-decoration: none; }
    & a:hover { text-decoration: underline; }
  }
  .mk-wishlist-item-options, .mk-wishlist-item-added { margin: 0; color: var(--muted-foreground); font-size: 0.8125rem; }
  .mk-wishlist-item-stock { display: inline-flex; align-items: center; gap: 0.375rem; margin: 0.25rem 0 0; font-size: 0.8125rem; font-weight: 600;
    &::before { content: ""; width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: currentColor; }
    &[data-stock="in"] { color: #15803d; }
    &[data-stock="low"] { color: #b45309; }
    &[data-stock="out"] { color: var(--muted-foreground); }
  }
  .mk-wishlist-item-price { font-variant-numeric: tabular-nums; }
  .mk-wishlist-item-actions { display: flex; align-items: center; gap: 0.25rem; }
  .mk-wishlist-item-remove { display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted-foreground); cursor: pointer;
    & svg { width: 1rem; height: 1rem; }
    &:hover { background: var(--accent); color: var(--destructive); }
    &:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
  }
  .mk-wishlist-item[data-variant="card"] {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    & .mk-wishlist-item-image { grid-column: 1 / -1; }
    & .mk-wishlist-item-actions { grid-column: 1 / -1; justify-content: space-between; }
  }
  /* -- Accessibility ------------------------------------------- */
  @media (forced-colors: active) {
    .mk-wishlist-item-stock::before { forced-color-adjust: none; }
  }
}

Comments, ideas or improvements? Edit this page's source on GitHub