ProductCard

The product tile used in grids and sliders, with price, badges, wishlist and add-to-cart.

Use ProductCard to show a product in a grid, slider or list. It already handles the price, sale and stock badges, the wishlist button and add-to-cart, so you only pass the product.

Example

app/components/home/FixedProducts.tsx
import { ProductCard } from '@salla.sa/twilight-theme-engine/product';
import type { Product } from '@salla.sa/twilight-theme-engine/types';

export function FixedProducts({ products }: { products: Product[] }) {
  return (
    <div className="grid grid-cols-2 gap-4 md:grid-cols-4">
      {products.map((product, index) => (
        <ProductCard key={product.id} product={product} index={index} />
      ))}
    </div>
  );
}
components/product-card

API

PropTypeDescription
productProductThe product to show. Required.
layout?"vertical" | "horizontal" | "fullImage" | "minimal" | "special"Card layout. Default: "vertical".
className?stringExtra class on the card.
withShadow?booleanAdds the card shadow class. Default: false.
withQuantity?booleanShows the remaining quantity, or an out-of-stock badge. Default: false.
withoutAddButton?booleanHides the add-to-cart button. Default: false.
index?numberPosition in a list. Delays the card animation by index x 100 ms. Default: 0.
imagePriority?booleanLoad the image eagerly. Use for the first cards above the fold. Default: false.
sizes?stringOverrides the image sizes hint.

Gotchas

  • It uses useMoney, useWishlist and Image inside, so it must be below TwilightProvider (your root route already is).
  • Out-of-stock products show a "notify me" button, unless the theme setting notify_when_available_in_card is turned off.
  • Product links are plain <a href> anchors, so opening a product reloads the page.
  • To change the card for the whole theme, wrap it (as the starter theme does with its own ProductCard) or replace it through the component registry. See Replace the product card.

A registry replacement is used only when product:card was registered twice: the registry keeps the earlier component as the "original", and ProductCard ignores a replacement that has no original. A single override on a fresh registry leaves the engine card in place. The choice is also made once, on the first render, so register before any card renders.

Next

On this page