Product cards

Products in an answer when someone asks what to buy: a side-by-side comparison, a scrolling row of results, one top pick in detail, a spec table that can show only the differences, and a product named inline with a hover card.

Loading preview…

Install

  1. 1

    Run this command in your Tailwind CSS project. It adds components/ai/product-card-default.tsx and installs its dependencies.

    $ npx shadcn@latest add https://gradientdeck.com/ai-components/r/product-card-default.json

Usage & API

Example

product-card-default.tsx
import { ProductComparison } from "@/components/ai/product-card-default"

<ProductComparison
  products={[]}
  recommendedId="…"
  saved={[]}
  onToggleSave={() => {}}
/>

Props ProductComparison

PropType & descriptionRequired
productsComparedProduct[]Required
recommendedIdstringRequired
savedstring[]Required
onToggleSave(id: string) => voidRequired

Dependencies

  • React
  • Tailwind CSS
  • motion
  • lucide-react
Implementation notes

Comparison lays the products in a row that snaps sideways on a narrow width and becomes three columns from the small breakpoint. Every card shows a drawn shot, a badge reading Best for and the reason, a bookmark, the maker, the rating and review count, the name, spec chips, a why sentence, and the price with at and the retailer. The recommended id gets an indigo border and an indigo badge. The others keep a light badge. The bookmark's pressed state is save, and the sample starts with one product saved. The prompt is noise cancelling headphones for a 14 hour flight to Tokyo, under $350. The reply names the Arden QH-7, which is the recommended card, best for flights, $329 at Best Buy, rated 4.7 from 2140 reviews. Beside it are the Lumen Audio Studio Pro 2, best for music, $279, and the Sola Air 3, best for value, $149. The why lines compare engine noise, sound and weight. Saving toggles the bookmark and does not otherwise change the card.

Choosing a layout

Use the comparison when there are a few serious options and you can say what each is best for, in a badge and one sentence. Use the results row when there are more hits than fit, some of them on sale, and the detail should open on demand rather than sit inline. Use the top pick when the advice is a single name plus where to pay and what you give up. Use the spec table when the decision is a grid of attributes, especially if many rows are identical and should get out of the way. Use the mention when the reply is a paragraph and the product is a noun in it.

A data table is the better fit when the rows are records from a query, with sorting and a CSV file, not a rating and a retailer. A chart is the better fit for a numeric series. Weather, itinerary, email draft and calendar event are the other rich answers in this catalog, and none of them are a catalog of goods. Do not force a forecast or a meeting into a product card because it has a title and a button. If the person asked what to buy, pick the product drawing that matches how many items you are willing to stand behind.

Which comparison card is the one being recommended?

The one whose id you pass as recommendedId. It gets the indigo border and the filled Best for badge. The other cards still say Best for, with their own reason, but the badge stays light and the border stays neutral. The sample passes the Arden headphones. The bookmark is separate. A saved product is not automatically the recommendation, and the sample in fact starts with a different card saved.

What does Show only differences hide?

Rows where every cell's text matches the first cell. It does not look at the score, and it does not hide a row just because no winner was highlighted. The header counts how many rows that removes. In the monitor sample, the shared VESA size, the lack of speakers and the three-year warranty disappear, while the stand stays because one monitor's stand text is shorter. Turn the switch off and those rows come back in their original order.