Skip to main content

Product card Pro

A product in a grid or list: its photo with sale and stock badges and a wishlist heart that fills with a pop, the title, rating and price (struck through on sale, read as "$32, was $40"), color swatches that swap the photo, and Add to cart, which says Added and then becomes a quantity stepper once it's in the cart. Prices are in cents.

import { ProductCard } from '@patine-ui/pro';
Loading…
<ProductCard
  product={mug}
  onPress={() => {}}
  onFavoriteChange={() => {}}
  onAddToCart={() => setQty(1)}
  quantity={qty}
  onQuantityChange={setQty}
  style={{ width: 280 }}
/>

Try the props​

Props
variant
size
design
<ProductCard
product={mug}
onAddToCart={add}
onFavoriteChange={save}
onPress={open}
/>

Example: a shop's grid​

A product listing: the cards share one row height, the wishlist hearts and quantities are the page's own state, and the cart total in the header adds them up.

Loading…
<View style={{ width: '100%', gap: 12 }}>
  <HStack justify="space-between">
    <Text weight="semibold">Home goods</Text>
    <Text color="textSecondary">{items ? `${items} in cart · €${(total / 100).toFixed(2)}` : 'Cart is empty'}</Text>
  </HStack>
  <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 12 }}>
    {PRODUCTS.map((p) => (
      <ProductCard
        key={p.id}
        product={p}
        currency="EUR"
        onPress={() => {}}
        onFavoriteChange={() => {}}
        onAddToCart={() => setCart((c) => ({ ...c, [p.id]: 1 }))}
        quantity={cart[p.id] ?? 0}
        onQuantityChange={(q) => setCart((c) => ({ ...c, [p.id]: q }))}
        style={{ flexGrow: 1, flexBasis: 180, maxWidth: 260 }}
      />
    ))}
  </View>
</View>

Variants​

variant is 'vertical' (photo on top), 'horizontal' (photo beside, for lists and carts), 'compact' (a small tile with the price) or 'overlay' (the text over the photo, for featured products). size is 'sm', 'md' or 'lg', and aspectRatio sets the photo's shape.

Loading…
<View style={{ gap: 24 }}>
  <View style={{ flexDirection: 'row', gap: 12 }}>
    {products.map((p) => (
      <ProductCard key={p.id} product={p} variant="compact" style={{ width: 150 }} />
    ))}
  </View>
  <ProductCard product={products[0]} variant="horizontal" onAddToCart={() => {}} onFavoriteChange={() => {}} style={{ width: 420 }} />
  <ProductCard product={products[1]} variant="overlay" size="lg" onFavoriteChange={() => {}} style={{ width: 260 }} />
</View>

Wishlist, swatches and the cart​

favorite, defaultFavorite and onFavoriteChange drive the heart (shown when onFavoriteChange is set, or with showFavorite); it's a switch for screen readers. swatch, defaultSwatch and onSwatchChange pick a color; a swatch with an image swaps the photo. onAddToCart(product, swatch) adds; give quantity and onQuantityChange and a stepper takes its place once it's above zero. Sold-out products (inStock: false or stockCount: 0) dim their photo and can't be added; under lowStockAt (5) they say "Only 3 left".

A grid that loads​

Loading…
<View style={{ flexDirection: 'row', gap: 16 }}>
  {items.map((p) => (
    <ProductCard key={p.id} product={p} loading={loading} onAddToCart={() => {}} size="sm" style={{ width: 200 }} />
  ))}
</View>

Your own image component​

renderImage({ source, style }) draws the photo yourself, e.g. with expo-image for caching.

Props​

PropTypeDefaultDescription
productProductCardData—{ id, title, subtitle?, image?, price, compareAtPrice?, rating?, reviewCount?, badges?, swatches?, inStock?, stockCount? }
variant'vertical' | 'horizontal' | 'compact' | 'overlay''vertical'
size'sm' | 'md' | 'lg''md'
aspectRationumber1 (4/5 overlay)
onPress(product) => void—The card is a button.
showFavorite / favorite / defaultFavorite / onFavoriteChangeThe heart.
swatch / defaultSwatch / onSwatchChangestringfirst swatch
onAddToCart(product, swatch) => void—
quantity / onQuantityChangenumber—A stepper once in the cart.
currency / locale / priceFormatter'USD'
lowStockAtnumber5
showRating / showDiscountbooleantrue
loadingbooleanfalseA placeholder of the card.
renderImage({ source, style }) => ReactNode—
density / labels / design / theme / style