{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"marketing-stats-metric-cards","type":"registry:block","title":"Metric Cards","files":[{"path":"components/blocks/marketing/stats/metric-cards.tsx","content":"import { Badge } from '@/components/ui/badge';\nimport { Card, CardContent, CardFooter } from '@/components/ui/card';\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipProvider,\n  TooltipTrigger,\n} from '@/components/ui/tooltip';\nimport { cn } from '@/lib/utils';\nimport {\n  ArrowDownRight,\n  ArrowUpRight,\n  HelpCircle,\n  InfoIcon,\n} from 'lucide-react';\n\ntype Metric = {\n  id: string;\n  name: string;\n  value: string;\n  rawValue: number;\n  change: number;\n  trend: 'up' | 'down' | 'neutral';\n  status: 'good' | 'warning' | 'critical';\n  period: string;\n  description: string;\n};\n\nexport default function MetricCards() {\n  // Sample data for metrics\n  const metrics: Metric[] = [\n    {\n      id: 'revenue',\n      name: 'Monthly Revenue',\n      value: '$48,283',\n      rawValue: 48283,\n      change: 12.6,\n      trend: 'up',\n      status: 'good',\n      period: 'vs. last month',\n      description:\n        'Total revenue generated during the current month from all products and services.',\n    },\n    {\n      id: 'new-users',\n      name: 'New Users',\n      value: '2,741',\n      rawValue: 2741,\n      change: 8.3,\n      trend: 'up',\n      status: 'good',\n      period: 'vs. last month',\n      description: 'Number of new user registrations within the past 30 days.',\n    },\n    {\n      id: 'conversion',\n      name: 'Conversion Rate',\n      value: '3.6%',\n      rawValue: 3.6,\n      change: -0.8,\n      trend: 'down',\n      status: 'warning',\n      period: 'vs. last month',\n      description:\n        'Percentage of visitors who completed a desired action (signup, purchase, etc).',\n    },\n    {\n      id: 'churn',\n      name: 'Monthly Churn',\n      value: '1.2%',\n      rawValue: 1.2,\n      change: -0.3,\n      trend: 'down',\n      status: 'good',\n      period: 'vs. last month',\n      description:\n        'Percentage of subscribers who canceled their subscription this month.',\n    },\n    {\n      id: 'cac',\n      name: 'Customer Acq. Cost',\n      value: '$48.32',\n      rawValue: 48.32,\n      change: 5.7,\n      trend: 'up',\n      status: 'warning',\n      period: 'vs. last month',\n      description:\n        'Average cost to acquire a new customer, including marketing and sales expenses.',\n    },\n    {\n      id: 'ltv',\n      name: 'Customer LTV',\n      value: '$452',\n      rawValue: 452,\n      change: 3.2,\n      trend: 'up',\n      status: 'good',\n      period: 'vs. last month',\n      description: 'Predicted lifetime value of an average customer.',\n    },\n    {\n      id: 'active-users',\n      name: 'Weekly Active Users',\n      value: '14,583',\n      rawValue: 14583,\n      change: -2.1,\n      trend: 'down',\n      status: 'warning',\n      period: 'vs. last week',\n      description:\n        'Number of unique users who performed an action in the past 7 days.',\n    },\n    {\n      id: 'engagement',\n      name: 'Avg. Engagement',\n      value: '4.2 min',\n      rawValue: 4.2,\n      change: 11.7,\n      trend: 'up',\n      status: 'good',\n      period: 'vs. last month',\n      description:\n        'Average time users spend actively engaging with the product per session.',\n    },\n    {\n      id: 'support',\n      name: 'Support Response',\n      value: '42 min',\n      rawValue: 42,\n      change: 14.3,\n      trend: 'up',\n      status: 'critical',\n      period: 'vs. last month',\n      description:\n        'Average time to first response for customer support tickets.',\n    },\n  ];\n\n  // Helper function to get appropriate styles based on status\n  const getStatusStyles = (status: Metric['status']) => {\n    switch (status) {\n      case 'good':\n        return 'border-emerald-200 dark:border-emerald-950 bg-emerald-50 dark:bg-emerald-950/30';\n      case 'warning':\n        return 'border-amber-200 dark:border-amber-950 bg-amber-50 dark:bg-amber-950/30';\n      case 'critical':\n        return 'border-rose-200 dark:border-rose-950 bg-rose-50 dark:bg-rose-950/30';\n      default:\n        return '';\n    }\n  };\n\n  // Helper function to get trend styles\n  const getTrendStyles = (trend: Metric['trend']) => {\n    switch (trend) {\n      case 'up':\n        return 'text-emerald-600 dark:text-emerald-400';\n      case 'down':\n        return 'text-rose-600 dark:text-rose-400';\n      default:\n        return 'text-muted-foreground';\n    }\n  };\n\n  // Helper function to get trend icons\n  const getTrendIcon = (trend: Metric['trend'], status: Metric['status']) => {\n    // For metrics like \"churn\" where down is good\n    const isInverseMetric = status === 'good' && trend === 'down';\n    const isPositive =\n      (trend === 'up' && status !== 'critical') || isInverseMetric;\n\n    if (trend === 'up') {\n      return (\n        <ArrowUpRight\n          className={cn(\n            'h-4 w-4',\n            isPositive ? 'text-emerald-500' : 'text-rose-500'\n          )}\n        />\n      );\n    } else if (trend === 'down') {\n      return (\n        <ArrowDownRight\n          className={cn(\n            'h-4 w-4',\n            isPositive ? 'text-emerald-500' : 'text-rose-500'\n          )}\n        />\n      );\n    }\n    return null;\n  };\n\n  // Calculate total percentages for the summary\n  const getStatusSummary = () => {\n    const total = metrics.length;\n    const goodCount = metrics.filter((m) => m.status === 'good').length;\n    const warningCount = metrics.filter((m) => m.status === 'warning').length;\n    const criticalCount = metrics.filter((m) => m.status === 'critical').length;\n\n    return {\n      good: Math.round((goodCount / total) * 100),\n      warning: Math.round((warningCount / total) * 100),\n      critical: Math.round((criticalCount / total) * 100),\n    };\n  };\n\n  const statusSummary = getStatusSummary();\n\n  return (\n    <TooltipProvider>\n      <div className=\"container mx-auto px-4 py-24 md:px-6 lg:py-32 2xl:max-w-[1400px]\">\n        <div className=\"mx-auto max-w-5xl\">\n          <div className=\"mb-12 text-center\">\n            <Badge className=\"mb-2\">Dashboard</Badge>\n            <h2 className=\"text-3xl font-bold md:text-4xl\">Business Metrics</h2>\n            <p className=\"text-muted-foreground mx-auto mt-3 max-w-2xl\">\n              Real-time overview of our key performance indicators\n            </p>\n          </div>\n\n          {/* Status Summary */}\n          <div className=\"mb-8 grid grid-cols-3 gap-4\">\n            <div className=\"rounded-lg border border-emerald-200 bg-emerald-50 p-4 text-center dark:border-emerald-950 dark:bg-emerald-950/30\">\n              <div className=\"text-2xl font-bold text-emerald-600 dark:text-emerald-400\">\n                {statusSummary.good}%\n              </div>\n              <div className=\"text-muted-foreground text-sm\">On Target</div>\n            </div>\n            <div className=\"rounded-lg border border-amber-200 bg-amber-50 p-4 text-center dark:border-amber-950 dark:bg-amber-950/30\">\n              <div className=\"text-2xl font-bold text-amber-600 dark:text-amber-400\">\n                {statusSummary.warning}%\n              </div>\n              <div className=\"text-muted-foreground text-sm\">\n                Needs Attention\n              </div>\n            </div>\n            <div className=\"rounded-lg border border-rose-200 bg-rose-50 p-4 text-center dark:border-rose-950 dark:bg-rose-950/30\">\n              <div className=\"text-2xl font-bold text-rose-600 dark:text-rose-400\">\n                {statusSummary.critical}%\n              </div>\n              <div className=\"text-muted-foreground text-sm\">Critical</div>\n            </div>\n          </div>\n\n          {/* Metric Cards */}\n          <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n            {metrics.map((metric) => (\n              <Card\n                key={metric.id}\n                className={cn(\n                  'overflow-hidden border p-0',\n                  getStatusStyles(metric.status)\n                )}\n              >\n                <CardContent className=\"p-6\">\n                  <div className=\"mb-4 flex items-center justify-between\">\n                    <div className=\"flex items-center\">\n                      <h3 className=\"font-medium\">{metric.name}</h3>\n                      <Tooltip>\n                        <TooltipTrigger asChild>\n                          <button className=\"text-muted-foreground hover:text-foreground ml-1.5\">\n                            <HelpCircle className=\"h-3.5 w-3.5\" />\n                          </button>\n                        </TooltipTrigger>\n                        <TooltipContent>\n                          <p className=\"max-w-xs text-sm\">\n                            {metric.description}\n                          </p>\n                        </TooltipContent>\n                      </Tooltip>\n                    </div>\n                  </div>\n\n                  <div className=\"flex items-baseline justify-between\">\n                    <div className=\"text-2xl font-bold\">{metric.value}</div>\n                    <div className=\"flex items-center\">\n                      <span\n                        className={cn(\n                          'text-sm font-medium',\n                          getTrendStyles(metric.trend)\n                        )}\n                      >\n                        {metric.change > 0 ? '+' : ''}\n                        {metric.change}%\n                      </span>\n                      <span className=\"ml-1\">\n                        {getTrendIcon(metric.trend, metric.status)}\n                      </span>\n                    </div>\n                  </div>\n\n                  <div className=\"text-muted-foreground mt-1 text-xs\">\n                    {metric.period}\n                  </div>\n                </CardContent>\n                <CardFooter\n                  className={cn(\n                    'bg-background/50 border-t px-6 !pt-3 !pb-3 text-xs',\n                    metric.status === 'good'\n                      ? 'border-emerald-200 dark:border-emerald-950/50'\n                      : metric.status === 'warning'\n                        ? 'border-amber-200 dark:border-amber-950/50'\n                        : 'border-rose-200 dark:border-rose-950/50'\n                  )}\n                >\n                  <div className=\"text-muted-foreground flex items-center\">\n                    <InfoIcon className=\"mr-1 h-3 w-3\" />\n                    {metric.status === 'good' && 'On target'}\n                    {metric.status === 'warning' && 'Needs attention'}\n                    {metric.status === 'critical' &&\n                      'Critical - action required'}\n                  </div>\n                </CardFooter>\n              </Card>\n            ))}\n          </div>\n        </div>\n      </div>\n    </TooltipProvider>\n  );\n}\n","type":"registry:component","target":"components/blocks/marketing/stats/metric-cards.tsx"},{"path":"components/ui/badge.tsx","content":"import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Slot } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst badgeVariants = cva(\n  \"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!\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-primary text-primary-foreground [a]:hover:bg-primary/80\",\n        secondary:\n          \"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80\",\n        destructive:\n          \"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\",\n        outline:\n          \"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground\",\n        ghost:\n          \"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50\",\n        link: \"text-primary underline-offset-4 hover:underline\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n    },\n  }\n)\n\nfunction Badge({\n  className,\n  variant = \"default\",\n  asChild = false,\n  ...props\n}: React.ComponentProps<\"span\"> &\n  VariantProps<typeof badgeVariants> & { asChild?: boolean }) {\n  const Comp = asChild ? Slot.Root : \"span\"\n\n  return (\n    <Comp\n      data-slot=\"badge\"\n      data-variant={variant}\n      className={cn(badgeVariants({ variant }), className)}\n      {...props}\n    />\n  )\n}\n\nexport { Badge, badgeVariants }\n","type":"registry:ui","target":"components/ui/badge.tsx"},{"path":"components/ui/card.tsx","content":"import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Card({\n  className,\n  size = \"default\",\n  ...props\n}: React.ComponentProps<\"div\"> & { size?: \"default\" | \"sm\" }) {\n  return (\n    <div\n      data-slot=\"card\"\n      data-size={size}\n      className={cn(\n        \"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\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-header\"\n      className={cn(\n        \"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\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-title\"\n      className={cn(\n        \"font-heading text-base leading-normal font-medium group-data-[size=sm]/card:text-sm\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardDescription({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-description\"\n      className={cn(\"text-sm text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction CardAction({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-action\"\n      className={cn(\n        \"col-start-2 row-span-2 row-start-1 self-start justify-self-end\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CardContent({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-content\"\n      className={cn(\"px-6 group-data-[size=sm]/card:px-4\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction CardFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-footer\"\n      className={cn(\n        \"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\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Card,\n  CardHeader,\n  CardFooter,\n  CardTitle,\n  CardAction,\n  CardDescription,\n  CardContent,\n}\n","type":"registry:ui","target":"components/ui/card.tsx"},{"path":"components/ui/tooltip.tsx","content":"\"use client\"\n\nimport * as React from \"react\"\nimport { Tooltip as TooltipPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\nfunction TooltipProvider({\n  delayDuration = 0,\n  ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n  return (\n    <TooltipPrimitive.Provider\n      data-slot=\"tooltip-provider\"\n      delayDuration={delayDuration}\n      {...props}\n    />\n  )\n}\n\nfunction Tooltip({\n  ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n  return <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n}\n\nfunction TooltipTrigger({\n  ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n  return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />\n}\n\nfunction TooltipContent({\n  className,\n  sideOffset = 0,\n  children,\n  ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n  return (\n    <TooltipPrimitive.Portal>\n      <TooltipPrimitive.Content\n        data-slot=\"tooltip-content\"\n        sideOffset={sideOffset}\n        className={cn(\n          \"z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95\",\n          className\n        )}\n        {...props}\n      >\n        {children}\n        <TooltipPrimitive.Arrow className=\"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground\" />\n      </TooltipPrimitive.Content>\n    </TooltipPrimitive.Portal>\n  )\n}\n\nexport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }\n","type":"registry:ui","target":"components/ui/tooltip.tsx"}],"description":"Bordered cards each holding one metric, a label, and a trend note. Use it to report KPIs in a structured layout on a homepage or product page.","dependencies":["class-variance-authority","lucide-react","radix-ui"]}