CatalystUI

DocsTemplate

Top Products Card

A card showing top or trending products.

Top Selling Products

PRODUCTVALUE

product

Backpack, Fits 15 Laptops

12,842 orders
$109.95
product

Mens Premium T-Shirts

2,421 orders
$22.3
product

Mens Cotton Jacket

5,921 orders
$55.99
product

Mens Casual Fit

921 orders
$15.99
product

Gold Chain Bracelet

8,232 orders
$695

Installations

Install clsx, and tailwind-merge to use avatar component.

npm install clsx tailwind-merge

Add the following function in lib/utils

import clsx, { type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cx(...args: ClassValue[]) {
  return twMerge(clsx(...args));
}

Copy paste the component

import {
  CardRoot,
  CardTitle,
  CardDescription,
} from "@/library/components/ui/card";
import { cx } from "@/lib/utils";
import Image from "next/image";
import React from "react";
 
function TopProductCard({
  products,
  className,
}: {
  products: {
    id: number;
    image: string;
    title: string;
    orders: string;
    price: number;
  }[];
  className?: string;
}) {
  return (
    <CardRoot
      className={cx(
        // base
        "w-full p-0",
        // className prop
        className
      )}
    >
      <CardTitle className="p-6">Top Selling Products</CardTitle>
      <CardDescription className="">
        <p className="px-6 pb-2 flex items-baseline justify-between text-xs font-bold text-gray-500">
          <span>PRODUCT</span>
          <span>VALUE</span>
        </p>
        {products.map((product) => (
          <CardRoot
            key={product.id}
            className="my-2 p-2 px-6 border-0 border-t rounded-none text-sm font-normal text-gray-800 dark:text-gray-100 flex items-baseline-last justify-between"
            showShadow={false}
          >
            <div className="flex gap-4">
              <Image
                src={product.image}
                className="border rounded"
                width={32}
                height={34}
                alt="product"
              />
              <div>
                <p className="">{product.title}</p>
                <small className="text-xs font-semibold">
                  {product.orders} orders
                </small>
              </div>
            </div>
            <span>{`$${product.price}`}</span>
          </CardRoot>
        ))}
      </CardDescription>
    </CardRoot>
  );
}
 
export default TopProductCard;

Usage

import TopProductCard from "@/library/blocks/topProductsCard";
 
const products = [
  {
    id: 1,
    title: "Backpack, Fits 15 Laptops",
    price: 109.95,
    orders: "12,842",
    category: "men's clothing",
    image: "https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg",
    rating: {
      rate: 3.9,
      count: 120,
    },
  },
  ...
];
 
export default function TopProductsView() {
  return (
    <CardRoot>
      <TopProductCard products={products} />
    </CardRoot>
  );
}

Next: Inivite Members Card

Found a bug? Report here.