---
name: product-card-minimal
title: Product Card Minimal
url: https://ui.frontic.com/components/sections/product-card-minimal.md
tier: sections
install: npx @frontic/ui add product-card-minimal
files:
  - components/sections/product-card-minimal/ProductCardMinimal.vue
  - components/sections/product-card-minimal/index.ts
  - components/sections/product-card-minimal/types.ts
registryDependencies:
  - badge
  - card
  - image
  - price
  - product
  - rating
  - swatch-group
  - use-product-sibling
---

# Product Card Minimal

Quiet linked product tile with colour pills, name and subtitle, rating, colour count and price.

## Install

```sh
npx @frontic/ui add product-card-minimal
```

Built from: [Badge](https://ui.frontic.com/components/ui/badge.md), [Card](https://ui.frontic.com/components/ui/card.md), [Image](https://ui.frontic.com/components/ui/image.md), [Price](https://ui.frontic.com/components/ui/price.md), [Product](https://ui.frontic.com/lib/product.md), [Rating](https://ui.frontic.com/components/ui/rating.md), [Swatch Group](https://ui.frontic.com/components/ui/swatch-group.md), [Use Product Sibling](https://ui.frontic.com/composables/use-product-sibling.md)

## Examples

```vue
<script setup lang="ts">
import { ProductCardMinimal, type Product } from '@/components/sections/product-card-minimal'

const product: Product = {
  name: 'TrailMaster 22',
  key: 'trailmaster-22',
  description: 'Equipment · Backpacks · 20L',
  link: { path: 'https://sw.demo-shop.com/trailmaster-22-4d39c9d9' },
  price: { amount: 14100, currency: 'EUR' },
  cover: { src: 'https://static.frontic.com/cdn-cgi/image/width=640,format=auto/ui/products/trailmaster-22.jpg' },
  rating: 4.8,
  reviewCount: 64,
  badge: 'Bestseller',
}
</script>

<template>
  <div class="mx-auto w-full max-w-xs">
    <ProductCardMinimal :product="product" />
  </div>
</template>
```

## API reference

### ProductCardMinimal

Shows a product with its image, name, price and number of colours.

Styling: [`section-title`](https://ui.frontic.com/DESIGN.md#section-title); [`hint`](https://ui.frontic.com/DESIGN.md#hint); [`meta`](https://ui.frontic.com/DESIGN.md#meta). Change them there and every part that extends them follows.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `product` (required) | `Product` |  | The product the card shows; its `badge`, `clearout` and `inStore` fields add badges over the image. |
| `colorCountLabel` | `((count: number) => string)`: `(count: number): string` | ``${count} ${count === 1 ? 'Color' : 'Colors'}`` | Text beside the rating that says how many colours the product comes in. |
| `clearoutLabel` | `string` | `'Clearout'` | Shown on the badge of a product marked `clearout`. |
| `inStoreLabel` | `string` | `'In Store'` | Shown on the badge of a product that is available in store. |
| `locale` | `string` |  | BCP 47 locale the price is formatted in, e.g. `de-DE`; the ConfigProvider's when left out. |
| `ratingLabel` | `((score: number, max: number) => string)`: `(score: number, max: number): string` |  | Builds the rating's screen-reader name from the score, to one decimal, and the top of the scale; `4.6 out of 5` when left out. |
| `surface` | `'raised' \| 'bare'` | `'raised'` | Bare drops the edge, shadow and inset, for a section placed inside another Card. |
| `class` | `ClassValue` |  | Classes added to the part's own element, after its recipe classes. |

| Data attribute | Values | Description |
| --- | --- | --- |
| `data-surface` | `'raised' \| 'bare'` | Carries the `surface` prop. |

## Exports

```ts
import { type Product, type ProductSibling } from '@/components/sections/product-card-minimal'
```

- `Product`, `ProductSibling`: from [Product](https://ui.frontic.com/lib/product.md)

## Styling

| Part | Recipe |
| --- | --- |
| `image` | [`product-card-minimal-image`](https://ui.frontic.com/DESIGN.md#product-card-minimal-image) |
| `section-title` | [`section-title`](https://ui.frontic.com/DESIGN.md#section-title) |
| `hint` | [`hint`](https://ui.frontic.com/DESIGN.md#hint) |
| `meta` | [`meta`](https://ui.frontic.com/DESIGN.md#meta) |
| `focus-ring` | [`focus-ring`](https://ui.frontic.com/DESIGN.md#focus-ring) |

States with a look of their own: hover.

## Source

`components/sections/product-card-minimal/ProductCardMinimal.vue`

```vue
<script lang="ts">
/** Shows a product with its image, name, price and number of colours. */
export default {}
</script>

<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import type { Product } from './types'
import { computed } from 'vue'
import { useProductSibling } from '@library/composables/use-product-sibling'
import { Badge } from '@library/components/ui/badge'
import { Card, CardContent, CardImage } from '@library/components/ui/card'
import { Image } from '@library/components/ui/image'
import { Price } from '@library/components/ui/price'
import { Rating } from '@library/components/ui/rating'
import { SwatchGroup, SwatchGroupItem } from '@library/components/ui/swatch-group'

const props = withDefaults(
  defineProps<{
    /** The product the card shows; its `badge`, `clearout` and `inStore` fields add badges over the image. */
    product: Product
    /** Text beside the rating that says how many colours the product comes in. */
    colorCountLabel?: (count: number) => string
    /** Shown on the badge of a product marked `clearout`. */
    clearoutLabel?: string
    /** Shown on the badge of a product that is available in store. */
    inStoreLabel?: string
    /** BCP 47 locale the price is formatted in, e.g. `de-DE`; the ConfigProvider's when left out. */
    locale?: string
    /** Builds the rating's screen-reader name from the score, to one decimal, and the top of the scale; `4.6 out of 5` when left out. */
    ratingLabel?: (score: number, max: number) => string
    /** Bare drops the edge, shadow and inset, for a section placed inside another Card. */
    surface?: 'raised' | 'bare'
    class?: HTMLAttributes['class']
  }>(),
  {
    surface: 'raised',
    colorCountLabel: (count: number) => `${count} ${count === 1 ? 'Color' : 'Colors'}`,
    clearoutLabel: 'Clearout',
    inStoreLabel: 'In Store',
  },
)

const { selected: selectedSibling, cover } = useProductSibling(() => props.product)
const siblingCount = computed(() => props.product.siblings?.items?.length ?? 0)
</script>

<template>
  <Card :surface="surface" :class="['group', props.class]">
    <CardImage class="relative">
      <a :href="product.link?.path ?? '#'" class="group/link relative block outline-none">
        <div data-slot="product-card-minimal-image" class="fui-product-card-minimal-image overflow-hidden">
          <Image :src="cover" :alt="product.name" class="aspect-3/4 w-full transition-transform duration-500 ease-out group-hover:scale-105" />
        </div>
        <span data-slot="focus-ring" aria-hidden="true" class="pointer-events-none absolute inset-0 z-10 group-focus-visible/link:fui-focus-ring group-focus-visible/link:-outline-offset-3" />
        <div v-if="product.badge || product.clearout || product.inStore" class="absolute top-3 inset-s-3 flex flex-col items-start gap-1">
          <Badge v-if="product.badge" variant="promo">{{ product.badge }}</Badge>
          <Badge v-if="product.clearout" variant="discount">{{ clearoutLabel }}</Badge>
          <Badge v-if="product.inStore" variant="success">{{ inStoreLabel }}</Badge>
        </div>
      </a>
    </CardImage>
    <CardContent class="flex flex-col gap-3">
      <div class="flex flex-col gap-0.5">
        <h3 data-slot="section-title" class="fui-section-title">
          {{ product.name }}
        </h3>
        <p v-if="product.description" data-slot="hint" class="fui-hint">
          {{ product.description }}
        </p>
      </div>

      <SwatchGroup v-if="product.siblings?.items?.length" v-model="selectedSibling" type="single" size="xs" shape="pill" label-class="sr-only">
        <SwatchGroupItem
          v-for="sibling in product.siblings.items.slice(0, 5)"
          :key="sibling.key"
          :value="sibling.key"
          :hex="sibling.colors?.exactColorHex"
          :label="sibling.colors?.exactColorName ?? sibling.name"
        />
      </SwatchGroup>

      <div v-if="product.rating || siblingCount" class="flex items-center justify-between gap-2">
        <Rating v-if="product.rating" :rating="product.rating" :label="ratingLabel" size="sm" />
        <p v-if="siblingCount" data-slot="meta" class="fui-meta">
          {{ colorCountLabel(siblingCount) }}
        </p>
      </div>

      <Price :price="product.price" :locale="locale" :show-discount="false" />
    </CardContent>
  </Card>
</template>
```

`components/sections/product-card-minimal/types.ts`

```ts
export type { Product, ProductSibling } from '@library/lib/product'
```
