CLI previewInstall commands shown on this site are not released yet.

DocsComponentsCommerce

ProductCard

React example follows below.
ts
import { ProductCard } from "@grassroot/ui-react";
<ProductCard
name="Forged steel trowel"
price={3200}
compareAt={4000}
image="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300'%3E%3Crect width='400' height='300' fill='%23e8e8ea'/%3E%3Crect x='140' y='90' width='120' height='120' rx='8' fill='%23c9c9cf'/%3E%3C/svg%3E"
rating={4.8}
reviewCount={64}
badge="Sale"
onAddToCart={() => {}}
/>
ts
<script setup lang="ts">
import { ProductCard } from "@grassroot/ui-vue";
</script>
<template>
<ProductCard
name="Forged steel trowel"
:price="3200"
:compare-at="4000"
image="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300'%3E%3Crect width='400' height='300' fill='%23e8e8ea'/%3E%3Crect x='140' y='90' width='120' height='120' rx='8' fill='%23c9c9cf'/%3E%3C/svg%3E"
:rating="4.8"
:review-count="64"
badge="Sale"
@add-to-cart="undefined"
/>
</template>
ts
import { Component } from "@angular/core";
import { GrassrootProductCard } from "@grassroot/ui-angular";
@Component({
selector: "app-example",
standalone: true,
imports: [GrassrootProductCard],
template: `
<grassroot-product-card
name="Forged steel trowel"
[price]="3200"
[compareAt]="4000"
image="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300'%3E%3Crect width='400' height='300' fill='%23e8e8ea'/%3E%3Crect x='140' y='90' width='120' height='120' rx='8' fill='%23c9c9cf'/%3E%3C/svg%3E"
[rating]="4.8"
[reviewCount]="64"
badge="Sale"
(addToCart)="undefined"
/>
`,
})
export class ExampleComponent {
}
ts
<script lang="ts">
import { ProductCard } from "@grassroot/ui-svelte";
</script>
<ProductCard
name="Forged steel trowel"
price={3200}
compareAt={4000}
image="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300'%3E%3Crect width='400' height='300' fill='%23e8e8ea'/%3E%3Crect x='140' y='90' width='120' height='120' rx='8' fill='%23c9c9cf'/%3E%3C/svg%3E"
rating={4.8}
reviewCount={64}
badge="Sale"
onAddToCart={() => {}}
/>
ts
import { ProductCard } from "@grassroot/ui-solid";
export function Example() {
return (
<>
<ProductCard
name="Forged steel trowel"
price={3200}
compareAt={4000}
image="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300'%3E%3Crect width='400' height='300' fill='%23e8e8ea'/%3E%3Crect x='140' y='90' width='120' height='120' rx='8' fill='%23c9c9cf'/%3E%3C/svg%3E"
rating={4.8}
reviewCount={64}
badge="Sale"
onAddToCart={() => {}}
/>
</>
);
}

Installation

bash
pnpm dlx grassroot add ui/product-card
bash
npx grassroot@latest add ui/product-card
bash
yarn dlx grassroot add ui/product-card
bash
bunx grassroot add ui/product-card

API Reference

ProductCardProps
PropTypeDefault
namerequiredstring
pricerequiredPrice in minor units.number
compareAtOriginal price in minor units — shows a struck-through "was".number | undefined
currencyISO 4217 code.string | undefined"USD"
imagerequiredstring
imageAltstring | undefined
ratingAverage rating 0..5. Omit to hide the stars.number | undefined
reviewCountnumber | undefined
badgeCorner flag, e.g. "Sale" / "New".string | undefined
badgeTone"info" | "success" | "neutral" | "accent" | undefined"accent"
wishlistedboolean | undefined
onToggleWishlist((pressed: boolean) => void) | undefined
onAddToCart(() => void) | undefined
classNamestring | undefined