Product Card
Products the agent found, with image, rating, price and seller, in a row that scrolls.
Concept, not a real feature. Designed from Family's wallet tiles with a hairline, the overlay badge, 16/600 amounts and the teal gradient for the seller icon. Concept, not a real feature. Family has no shop. The struck original price and the rating row are guesses.
import { ProductCard } from "@replicas/ui";
const lens = (length: number) =>
`data:image/svg+xml,${encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160"><rect width="160" height="160" fill="#fff"/><g transform="translate(80 80)"><rect x="${-length / 2}" y="-34" width="${length}" height="68" rx="8" fill="#1c1c1e"/><rect x="${-length / 2 + 6}" y="-38" width="10" height="76" rx="3" fill="#2c2c2e"/><rect x="${length / 2 - 18}" y="-36" width="14" height="72" rx="3" fill="#3a3a3c"/><g fill="#48484a">${Array.from({ length: Math.floor(length / 6) }, (_, i) => `<rect x="${-length / 2 + 22 + i * 4}" y="-34" width="1.5" height="68"/>`).join("")}</g></g></svg>`,
)}`;
const products = [
{ title: "Prime 20mm f/2.8 Lens", src: lens(48), rating: 5, count: 1, price: "€142.95", was: "€189.00", seller: "Pergear", badge: "Biggest discount" },
{ title: "Prime 56mm f/1.7 Lens", src: lens(72), rating: 4.6, count: 128, price: "€219.00", seller: "Simply Shopping" },
{ title: "Prime 33mm f/1.4 Lens", src: lens(64), price: "€223.12", seller: "Meike" },
];
export default function ProductCardDemo() {
return (
<ProductCard.List style={{ width: "100%", maxWidth: 640 }}>
{products.map((product) => (
<ProductCard.Root key={product.title} href="#product">
<ProductCard.Media src={product.src} alt="">
{product.badge ? <ProductCard.Badge>{product.badge}</ProductCard.Badge> : null}
</ProductCard.Media>
<ProductCard.Body>
<ProductCard.Title>{product.title}</ProductCard.Title>
{product.rating ? <ProductCard.Rating value={product.rating} count={product.count} /> : null}
<ProductCard.Price>
{product.price}
{product.was ? <ProductCard.OriginalPrice>{product.was}</ProductCard.OriginalPrice> : null}
</ProductCard.Price>
<ProductCard.Seller icon={product.seller.charAt(0)}>{product.seller}</ProductCard.Seller>
</ProductCard.Body>
</ProductCard.Root>
))}
</ProductCard.List>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the Product Card in the Family style: the measured tokens, the CSS and the structure.
Show Prompt
# Family Product Card
Products the agent found, with image, rating, price and seller, in a row that scrolls.
Build a Product Card in this project that looks and behaves like Family's. Measured from the running Family app (app.family.co). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.
Fidelity: Concept, not a real feature. Designed from Family's wallet tiles with a hairline, the overlay badge, 16/600 amounts and the teal gradient for the seller icon. Concept, not a real feature. Family has no shop. The struck original price and the rating row are guesses.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--body-color` | `#222` | `#fff` |
| `--body-color-muted` | `#17171780` | `#ffffff80` |
| `--icon-color-tertiary` | `#adadad` | `#adadad` |
| `--body-bg` | `#fff` | `#1c1c1c` |
| `--hr-color` | `#f0f0f0` | `#ffffff0d` |
| `--focus-color` | `#007aff80` | `#007aff80` |
| `--overlay-color` | `#fff` | `#fff` |
| `--overlay-background` | `#171717` | `#171717` |
| `--card-teal-01` | `#0fcccc` | `#0fcccc` |
| `--card-teal-02` | `#59d9d9` | `#59d9d9` |
| `--card-yellow-01` | `#f2ae00` | `#f2ae00` |
| `--font-regular` | `"Family Inter", "Family Inter Fallback"` | `"Family Inter", "Family Inter Fallback"` |
| `--font-size-micro` | `0.6875rem` | `0.6875rem` |
| `--font-size-mini` | `0.8125rem` | `0.8125rem` |
| `--font-size-small` | `0.875rem` | `0.875rem` |
| `--font-size-regular` | `1rem` | `1rem` |
| `--font-weight-normal` | `400` | `400` |
| `--font-weight-medium` | `500` | `500` |
| `--font-weight-button` | `550` | `550` |
| `--font-weight-semibold` | `600` | `600` |
| `--letter-spacing-small` | `-0.00563rem` | `-0.00563rem` |
| `--letter-spacing-input` | `-0.01125rem` | `-0.01125rem` |
| `--radius-control` | `0.875rem` | `0.875rem` |
| `--radius-pill` | `1.5rem` | `1.5rem` |
| `--duration-press` | `10ms` | `10ms` |
| `--ease-spring-snappy` | `linear(0, 0.053, 0.1882, 0.3525, 0.537, 0.6988, 0.8378, 0.9543, 1.0327, 1.0832, 1.111, 1.1179, 1.1108, 1.0956, 1.0762, 1.0544, 1.0354, 1.019, 1.0053, 0.9961, 0.9899, 0.9869, 0.9861, 0.9869, 0.9887, 0.991, 0.9936, 0.9958, 0.9979, 0.9994, 1.0005, 1.0012, 1.0015, 1.0016, 1.0015, 1.0013, 1.001, 1.0008, 1.0005, 1.0002, 1)` | `linear(0, 0.053, 0.1882, 0.3525, 0.537, 0.6988, 0.8378, 0.9543, 1.0327, 1.0832, 1.111, 1.1179, 1.1108, 1.0956, 1.0762, 1.0544, 1.0354, 1.019, 1.0053, 0.9961, 0.9899, 0.9869, 0.9861, 0.9869, 0.9887, 0.991, 0.9936, 0.9958, 0.9979, 0.9994, 1.0005, 1.0012, 1.0015, 1.0016, 1.0015, 1.0013, 1.001, 1.0008, 1.0005, 1.0002, 1)` |
| `--duration-spring-snappy` | `615ms` | `615ms` |
## CSS
Scoped under `[data-style="family"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="family"] {
.ui-product-card-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
gap: 1rem 0.75rem;
}
.ui-product-card {
display: flex;
flex-direction: column;
min-width: 0;
border-radius: var(--radius-control);
outline: none;
color: var(--body-color);
font-family: var(--font-regular);
text-decoration: none;
transition: transform var(--duration-spring-snappy) var(--ease-spring-snappy);
@media (hover: hover) {
&:hover .ui-product-card-media img {
transform: scale(1.04);
}
}
&:active {
transform: scale(0.98);
transition-duration: var(--duration-press);
}
&:focus-visible .ui-product-card-media {
box-shadow:
0 0 0 2px var(--body-bg),
0 0 0 4px var(--focus-color);
}
}
.ui-product-card-media {
position: relative;
isolation: isolate;
display: block;
aspect-ratio: 1;
overflow: hidden;
border-radius: var(--radius-control);
background: var(--body-bg);
&::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
box-shadow: inset 0 0 0 1px var(--hr-color);
pointer-events: none;
}
& img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
transition: transform var(--duration-spring-snappy) var(--ease-spring-snappy);
}
}
.ui-product-card-badge {
position: absolute;
top: 0.5rem;
left: 0.5rem;
z-index: 1;
max-width: calc(100% - 1rem);
overflow: hidden;
padding: 0.25rem 0.5rem;
border-radius: var(--radius-pill);
background: var(--overlay-background);
color: var(--overlay-color);
font-size: var(--font-size-micro);
font-weight: var(--font-weight-button);
line-height: 0.875rem;
white-space: nowrap;
text-overflow: ellipsis;
}
.ui-product-card-body {
display: flex;
flex-direction: column;
gap: 0.25rem;
padding: 0.625rem 0.125rem 0;
}
.ui-product-card-title {
display: -webkit-box;
overflow: hidden;
color: var(--body-color);
font-size: var(--font-size-small);
font-weight: var(--font-weight-medium);
line-height: 1.125rem;
letter-spacing: var(--letter-spacing-small);
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.ui-product-card-rating {
display: inline-flex;
align-items: center;
gap: 0.25rem;
color: var(--body-color-muted);
font-size: var(--font-size-mini);
line-height: 1rem;
font-variant-numeric: tabular-nums;
& svg {
width: 0.75rem;
height: 0.75rem;
color: var(--card-yellow-01);
}
}
.ui-product-card-rating-value {
color: var(--body-color);
font-weight: var(--font-weight-medium);
}
.ui-product-card-price {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 0 0.375rem;
color: var(--body-color);
font-size: var(--font-size-regular);
font-weight: var(--font-weight-semibold);
line-height: 1.25rem;
letter-spacing: var(--letter-spacing-input);
font-variant-numeric: tabular-nums;
}
.ui-product-card-original-price {
color: var(--body-color-muted);
font-size: var(--font-size-mini);
font-weight: var(--font-weight-normal);
letter-spacing: var(--letter-spacing-small);
text-decoration-color: var(--icon-color-tertiary);
}
.ui-product-card-seller {
display: flex;
align-items: center;
gap: 0.375rem;
min-width: 0;
color: var(--body-color-muted);
font-size: var(--font-size-mini);
line-height: 1rem;
white-space: nowrap;
}
.ui-product-card-seller-icon {
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 1rem;
height: 1rem;
overflow: hidden;
border-radius: 50%;
background: linear-gradient(135deg, var(--card-teal-01) 0%, var(--card-teal-02) 100%);
color: #fff;
font-size: 0.5625rem;
font-weight: var(--font-weight-semibold);
line-height: 1;
& img,
& svg {
width: 100%;
height: 100%;
}
}
@media (prefers-reduced-motion: reduce) {
.ui-product-card,
.ui-product-card-media img {
transition: none;
}
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import type { ComponentProps, ReactNode } from "react";
import { join } from "./utils";
function List({ className, ...props }: ComponentProps<"div">) {
return <div className={join("ui-product-card-list", className)} {...props} />;
}
function Root({ className, ...props }: ComponentProps<"a">) {
return <a className={join("ui-product-card", className)} {...props} />;
}
type MediaProps = ComponentProps<"span"> & { src: string; alt?: string };
function Media({ className, src, alt = "", children, ...props }: MediaProps) {
return (
<span className={join("ui-product-card-media", className)} {...props}>
<img src={src} alt={alt} />
{children}
</span>
);
}
function Badge({ className, ...props }: ComponentProps<"span">) {
return <span className={join("ui-product-card-badge", className)} {...props} />;
}
function Body({ className, ...props }: ComponentProps<"span">) {
return <span className={join("ui-product-card-body", className)} {...props} />;
}
function Title({ className, ...props }: ComponentProps<"span">) {
return <span className={join("ui-product-card-title", className)} {...props} />;
}
type RatingProps = Omit<ComponentProps<"span">, "children"> & { value: number; count?: number };
function Rating({ className, value, count, ...props }: RatingProps) {
return (
<span className={join("ui-product-card-rating", className)} aria-label={`Rated ${value} out of 5${count === undefined ? "" : ` from ${count} reviews`}`} {...props}>
<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden>
<path d="M8 1.75l1.9 3.95 4.35.6-3.17 3.02.78 4.3L8 11.55 4.14 13.62l.78-4.3L1.75 6.3l4.35-.6z" />
</svg>
<span className="ui-product-card-rating-value" aria-hidden>
{value.toFixed(1)}
</span>
{count === undefined ? null : (
<span className="ui-product-card-rating-count" aria-hidden>
({count})
</span>
)}
</span>
);
}
function Price({ className, ...props }: ComponentProps<"span">) {
return <span className={join("ui-product-card-price", className)} {...props} />;
}
function OriginalPrice({ className, ...props }: ComponentProps<"s">) {
return <s className={join("ui-product-card-original-price", className)} {...props} />;
}
type SellerProps = ComponentProps<"span"> & { icon?: ReactNode };
function Seller({ className, icon, children, ...props }: SellerProps) {
return (
<span className={join("ui-product-card-seller", className)} {...props}>
{icon ? (
<span className="ui-product-card-seller-icon" aria-hidden>
{icon}
</span>
) : null}
{children}
</span>
);
}
export const ProductCard = {
List,
Root,
Media,
Badge,
Body,
Title,
Rating,
Price,
OriginalPrice,
Seller,
};
```
## Example
```tsx
import { ProductCard } from "@replicas/ui";
const lens = (length: number) =>
`data:image/svg+xml,${encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160"><rect width="160" height="160" fill="#fff"/><g transform="translate(80 80)"><rect x="${-length / 2}" y="-34" width="${length}" height="68" rx="8" fill="#1c1c1e"/><rect x="${-length / 2 + 6}" y="-38" width="10" height="76" rx="3" fill="#2c2c2e"/><rect x="${length / 2 - 18}" y="-36" width="14" height="72" rx="3" fill="#3a3a3c"/><g fill="#48484a">${Array.from({ length: Math.floor(length / 6) }, (_, i) => `<rect x="${-length / 2 + 22 + i * 4}" y="-34" width="1.5" height="68"/>`).join("")}</g></g></svg>`,
)}`;
const products = [
{ title: "Prime 20mm f/2.8 Lens", src: lens(48), rating: 5, count: 1, price: "€142.95", was: "€189.00", seller: "Pergear", badge: "Biggest discount" },
{ title: "Prime 56mm f/1.7 Lens", src: lens(72), rating: 4.6, count: 128, price: "€219.00", seller: "Simply Shopping" },
{ title: "Prime 33mm f/1.4 Lens", src: lens(64), price: "€223.12", seller: "Meike" },
];
export default function ProductCardDemo() {
return (
<ProductCard.List style={{ width: "100%", maxWidth: 640 }}>
{products.map((product) => (
<ProductCard.Root key={product.title} href="#product">
<ProductCard.Media src={product.src} alt="">
{product.badge ? <ProductCard.Badge>{product.badge}</ProductCard.Badge> : null}
</ProductCard.Media>
<ProductCard.Body>
<ProductCard.Title>{product.title}</ProductCard.Title>
{product.rating ? <ProductCard.Rating value={product.rating} count={product.count} /> : null}
<ProductCard.Price>
{product.price}
{product.was ? <ProductCard.OriginalPrice>{product.was}</ProductCard.OriginalPrice> : null}
</ProductCard.Price>
<ProductCard.Seller icon={product.seller.charAt(0)}>{product.seller}</ProductCard.Seller>
</ProductCard.Body>
</ProductCard.Root>
))}
</ProductCard.List>
);
}
```
## Foundations
The rest of the Family style, as a skill: https://replicas.raphaelsalaja.com/skills/family/SKILL.md