# Interactive Hover

> Stat cards that reveal extra detail or a chart when you hover over them. Use it when you want a number to expand into context on a feature page.

A shadcn/ui block from the [@shadcn-ui-blocks](https://www.shadcn-ui-blocks.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/shadcn-ui-blocks/marketing-stats-interactive-hover).

- Page, with a live preview: https://shadcn.exchange/r/shadcn-ui-blocks/marketing-stats-interactive-hover
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/shadcn-ui-blocks/marketing-stats-interactive-hover-light-4897d1342fb865f1.png
- Registry item: https://www.shadcn-ui-blocks.com/r/marketing-stats-interactive-hover.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://www.shadcn-ui-blocks.com/r/marketing-stats-interactive-hover.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `class-variance-authority`, `lucide-react`, `radix-ui`

## Files

### `components/blocks/marketing/stats/interactive-hover.tsx`

```tsx
import { useState } from 'react';
import { Badge } from '@/components/ui/badge';
import {
  Card,
  CardContent,
  CardFooter,
  CardHeader,
  CardTitle,
} from '@/components/ui/card';
import {
  LineChart,
  Users,
  ShoppingCart,
  BarChart3,
  ArrowUpRight,
  ArrowDownRight,
} from 'lucide-react';
import { cn } from '@/lib/utils';

export default function InteractiveHover() {
  const [hoveredCard, setHoveredCard] = useState<number | null>(null);

  const stats = [
    {
      title: 'Total Revenue',
      value: '$2.4M',
      change: '+18.2%',
      trend: 'up',
      icon: BarChart3,
      mainStat: '$2.4M this quarter',
      secondaryStat: '$1.96M last quarter',
      additionalInfo: [
        { label: 'Quarter over Quarter', value: '+18.2%' },
        { label: 'Year over Year', value: '+42.5%' },
        { label: 'Highest Month', value: 'September' },
      ],
    },
    {
      title: 'Average Order Value',
      value: '$124.32',
      change: '+5.4%',
      trend: 'up',
      icon: ShoppingCart,
      mainStat: '$124.32 per order',
      secondaryStat: '$117.92 last quarter',
      additionalInfo: [
        { label: 'Quarter over Quarter', value: '+5.4%' },
        { label: 'Year over Year', value: '+12.8%' },
        { label: 'Highest Category', value: 'Electronics' },
      ],
    },
    {
      title: 'Conversion Rate',
      value: '6.2%',
      change: '+1.8%',
      trend: 'up',
      icon: LineChart,
      mainStat: '6.2% of visitors convert',
      secondaryStat: '4.4% last quarter',
      additionalInfo: [
        { label: 'Quarter over Quarter', value: '+1.8%' },
        { label: 'Year over Year', value: '+3.2%' },
        { label: 'Top Traffic Source', value: 'Organic Search' },
      ],
    },
    {
      title: 'Monthly Active Users',
      value: '84.7K',
      change: '-2.3%',
      trend: 'down',
      icon: Users,
      mainStat: '84,723 active users',
      secondaryStat: '86,721 last quarter',
      additionalInfo: [
        { label: 'Quarter over Quarter', value: '-2.3%' },
        { label: 'Year over Year', value: '+15.7%' },
        { label: 'User Retention', value: '78.4%' },
      ],
    },
  ];

  return (
    <div className="container mx-auto px-4 py-24 md:px-6 lg:py-32 2xl:max-w-[1400px]">
      <div className="mx-auto max-w-6xl">
        <div className="mb-12 text-center">
          <Badge className="mb-2">Interactive Stats</Badge>
          <h2 className="text-3xl font-bold md:text-4xl">
            Key Performance Metrics
          </h2>
          <p className="text-muted-foreground mx-auto mt-3 max-w-2xl">
            Hover over each card to reveal detailed insights about our business
            metrics
          </p>
        </div>

        <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4">
          {stats.map((stat, index) => {
            const isHovered = hoveredCard === index;
            const IconComponent = stat.icon;

            return (
              <Card
                key={index}
                className={cn(
                  'relative overflow-hidden pb-0 shadow-sm transition-all duration-300',
                  isHovered ? 'shadow-md' : ''
                )}
                onMouseEnter={() => setHoveredCard(index)}
                onMouseLeave={() => setHoveredCard(null)}
              >
                <div
                  className={cn(
                    'from-primary/10 to-primary/5 absolute inset-0 bg-gradient-to-br opacity-0 transition-opacity duration-300',
                    isHovered ? 'opacity-100' : ''
                  )}
                >
                  <div className="bg-primary/10 absolute top-0 right-0 -mt-5 -mr-5 h-20 w-20 rounded-full blur-xl"></div>
                </div>

                <CardHeader className="pb-2">
                  <div className="flex items-start justify-between">
                    <div className="flex items-center">
                      <div className="bg-primary/10 mr-2 rounded-md p-1.5">
                        <IconComponent className="text-primary h-4 w-4" />
                      </div>
                      <CardTitle className="text-sm font-medium">
                        {stat.title}
                      </CardTitle>
                    </div>
                    <div
                      className={cn(
                        'flex items-center text-xs font-medium',
                        stat.trend === 'up'
                          ? 'text-emerald-500'
                          : 'text-rose-500'
                      )}
                    >
                      {stat.trend === 'up' ? (
                        <ArrowUpRight className="mr-0.5 h-3 w-3" />
                      ) : (
                        <ArrowDownRight className="mr-0.5 h-3 w-3" />
                      )}
                      {stat.change}
                    </div>
                  </div>
                </CardHeader>

                <CardContent className="pb-2">
                  <div className="text-3xl font-bold">{stat.value}</div>

                  <div
                    className={cn(
                      'mt-2 max-h-0 space-y-3 overflow-hidden opacity-0 transition-all duration-300',
                      isHovered ? 'max-h-40 opacity-100' : ''
                    )}
                  >
                    <div className="text-sm">
                      <div className="font-medium">{stat.mainStat}</div>
                      <div className="text-muted-foreground">
                        {stat.secondaryStat}
                      </div>
                    </div>

                    <div className="border-border space-y-1.5 border-t pt-2">
                      {stat.additionalInfo.map((info, i) => (
                        <div
                          key={i}
                          className="flex items-center justify-between text-xs"
                        >
                          <span className="text-muted-foreground">
                            {info.label}
                          </span>
                          <span className="font-medium">{info.value}</span>
                        </div>
                      ))}
                    </div>
                  </div>
                </CardContent>

                <CardFooter
                  className={cn(
                    'text-muted-foreground text-xs transition-all duration-300',
                    isHovered ? 'pb-3' : 'pb-4'
                  )}
                >
                  <div className="flex w-full justify-between">
                    <span>Last Updated</span>
                    <span>Today, 8:23 AM</span>
                  </div>
                </CardFooter>
              </Card>
            );
          })}
        </div>
      </div>
    </div>
  );
}
```

### `components/ui/badge.tsx`

```tsx
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"

import { cn } from "@/lib/utils"

const badgeVariants = cva(
  "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
        secondary:
          "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
        destructive:
          "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
        outline:
          "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
        ghost:
          "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
        link: "text-primary underline-offset-4 hover:underline",
      },
    },
    defaultVariants: {
      variant: "default",
    },
  }
)

function Badge({
  className,
  variant = "default",
  asChild = false,
  ...props
}: React.ComponentProps<"span"> &
  VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
  const Comp = asChild ? Slot.Root : "span"

  return (
    <Comp
      data-slot="badge"
      data-variant={variant}
      className={cn(badgeVariants({ variant }), className)}
      {...props}
    />
  )
}

export { Badge, badgeVariants }
```

### `components/ui/card.tsx`

```tsx
import * as React from "react"

import { cn } from "@/lib/utils"

function Card({
  className,
  size = "default",
  ...props
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
  return (
    <div
      data-slot="card"
      data-size={size}
      className={cn(
        "group/card flex flex-col gap-6 overflow-hidden rounded-xl bg-card py-6 text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
        className
      )}
      {...props}
    />
  )
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-header"
      className={cn(
        "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-6 group-data-[size=sm]/card:px-4 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-6 group-data-[size=sm]/card:[.border-b]:pb-4",
        className
      )}
      {...props}
    />
  )
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-title"
      className={cn(
        "font-heading text-base leading-normal font-medium group-data-[size=sm]/card:text-sm",
        className
      )}
      {...props}
    />
  )
}

function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-description"
      className={cn("text-sm text-muted-foreground", className)}
      {...props}
    />
  )
}

function CardAction({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-action"
      className={cn(
        "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
        className
      )}
      {...props}
    />
  )
}

function CardContent({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-content"
      className={cn("px-6 group-data-[size=sm]/card:px-4", className)}
      {...props}
    />
  )
}

function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-footer"
      className={cn(
        "flex items-center rounded-b-xl px-6 group-data-[size=sm]/card:px-4 [.border-t]:pt-6 group-data-[size=sm]/card:[.border-t]:pt-4",
        className
      )}
      {...props}
    />
  )
}

export {
  Card,
  CardHeader,
  CardFooter,
  CardTitle,
  CardAction,
  CardDescription,
  CardContent,
}
```
