Tally UI

ProductImage

ProductImage displays a connector-derived product image with configurable size and fit, automatic alt text, and no output when no image exists.

Import

import { ProductImage } from '@tallyui/components';

Usage

<ProductImage doc={productDocument} size={80} className="rounded-lg" />

Returns null if no image is available. The size prop controls width and height via the style prop (dynamic values can't be Tailwind classes).

Built on the Image primitive from @tallyui/primitives, which normalizes the image API across platforms with contentFit, alt, and placeholder support.

Props

PropTypeDefaultDescription
docanyrequiredRxDB product document
sizenumber60Image width and height in pixels
styleStyleProp<ImageStyle>—Style overrides, e.g. for dynamic sizing
showPlaceholderbooleanfalseRenders a same-size tile with the product's initial when there is no image, so rows and grids stay aligned; otherwise renders nothing
contentFit'cover' | 'contain' | 'fill' | 'none' | 'scale-down''cover'How the image fills its container
classNamestring—Override default styles

The alt text is automatically derived from the product name via getName(doc).

Default classes: rounded

Trait mapping

ConnectorImage source
WooCommercedoc.images[0].src
Medusadoc.thumbnail or doc.images[0].url
Shopifydoc.image.src or doc.images[0].src
Venduredoc.featuredAsset.preview or doc.assets[0].preview

Live demo