Moumen Soliman

Stats

Cards

About

Here is Stats component

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Stats to your project and fits it to your theme.

Code

How Stats is used: the demo's code. The component's own source comes with a free account.

Usage.tsx


  
  import type React from "react";
  import {
    Card,   
    CardContent,
    CardHeader,
    CardTitle,
  } from "@/components/ui/card";
  import { Delta, DeltaIcon, DeltaValue } from "@/components/ui/delta";

  type Stat = {
    label: string;
    value: string;
    delta: number;
  };

  const stats = [
    { label: "Active users",    value: "847",     delta: 3.1 },
    { label: "Revenue",         value: "$18,290", delta: 12.4 },
    { label: "Conversion Rate", value: "3.28%",   delta: -0.4 },
  ] as const;

  export function DashboardStats() {
    return (
      <>
        {stats.map((s) => (
          <StatCard key={s.label} stat={s} />
        ))}
      </>
    );
  }

  import { clsx, type ClassValue } from "clsx";
  import { twMerge } from "tailwind-merge";
  
  function cn(...inputs: ClassValue[]) {
    return twMerge(clsx(inputs));
  }
  function StatCard({
    stat,
    className,
    ...props
  }: React.ComponentProps<typeof Card> & { stat: Stat }) {
    const { label, value, delta } = stat;
    return (
      <Card
        className={cn(
          "rounded-none bg-background shadow-none ring-0 gap-1 py-4",
          className
        )}  
        {...props}
      >
        <CardHeader className="flex flex-row items-baseline justify-between gap-2 px-4 pb-0">
          <CardTitle className="font-normal text-muted-foreground text-xs tracking-wide truncate">
            {label}
          </CardTitle>
          <Delta value={delta} className="text-xs shrink-0">
            <DeltaIcon />
            <DeltaValue />
          </Delta>
        </CardHeader>
        <CardContent className="flex flex-row items-center gap-2 px-4 pt-0">
          <p className="font-medium text-xl tabular-nums">{value}</p>
        </CardContent>
      </Card>
    );
  }

  export default DashboardStats;

More by Moumen Soliman

View all
  • Interactive Logs Table

    Interactive Logs Table

    1.4K
  • Glass Blog Card

    Glass Blog Card

    1.1K
  • Glowy Waves Hero

    Glowy Waves Hero

    921
  • Gallery Grid with Lightbox

    Gallery Grid with Lightbox

    790
  • Expanding Search Dock

    Expanding Search Dock

    762
  • Glassmorphism Portfolio

    Glassmorphism Portfolio

    653
  • Hero Section

    Hero Section

    605
  • Glass Checkout Card

    Glass Checkout Card

    483

More in Cards

View all
  • Stats cards with links

    Stats cards with links

    33
  • Course Design Cards

    Course Design Cards

    1.1K
  • Card

    Card

    70
  • Statistics Card 2

    Statistics Card 2

    264
  • Statistics Card 10

    Statistics Card 10

    263
  • Card

    Card

    17
  • Card Studio

    Card Studio

    9
  • The Item one

    The Item one

    3