About
Insight carousel with embedded mini charts for AI chat and dashboards: two-series stat tiles with a line chart, an anomaly chart with metric toggle, and a labelled segmented allocation bar. Themed with shadcn variables, all content via props.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Insight Cards to your project and fits it to your theme.
Code
How Insight Cards is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import InsightCards, { AllocationCard, AnomalyCard, CompareCard, Entity, Mono } from "@/components/ui/insight-cards";
/* all content lives here; the component only renders what it is given */
const money = (v: number) => `$${Math.round(v).toLocaleString("en-US")}`;
export default function InsightCardsDemo() {
return (
<div className="flex min-h-[520px] items-start justify-center bg-background p-8">
<InsightCards
title="Insights"
onPrompt={(prompt) => console.log("prompt:", prompt)}
pages={[
{
key: "compare",
prose: (
<>
The worst performer in your <Entity name="Creamery" color="#f97316" /> is Rocky Road — down <Mono tone="down">-6%</Mono> or <Mono tone="down">-$2,453.44</Mono>.
</>
),
card: (
<CompareCard
series={[
{ name: "Mint Chip", values: [-2.9, -3.4, -3.05, -3.86, -3.52, -4.1, -3.82, -4.41], sub: "-$2,377.66", tone: "down", color: "#f97316" },
{ name: "Pistachio", values: [0.22, 0.58, 0.42, 0.91, 0.76, 1.08, 0.96, 1.15], sub: "+$617.22", tone: "up", color: "#3b82f6" },
]}
/>
),
prompt: "Should I rebalance flavors?",
},
{
key: "anomaly",
prose: (
<>
Unusually high freezer bill on <span className="font-medium text-foreground">Dec 13</span> — <Mono tone="down">+$1,834.66</Mono> above your average.
</>
),
card: (
<AnomalyCard
title="High freezer spend"
delta="+$1,834.66"
deltaTone="down"
color="#ef4444"
metrics={[
{ key: "spend", label: "Spend", values: [274, 289, 264, 307, 331, 1210, 1718, 2112], threshold: "$2,112 threshold", formatValue: money },
{ key: "usage", label: "Usage", values: [18, 19, 17, 21, 22, 58, 81, 96], threshold: "82 kWh threshold", formatValue: (v) => `${Math.round(v)} kWh` },
]}
footer={{ value: "$2,112", label: "spent this cycle", note: "vs 3-month avg" }}
/>
),
prompt: "Get tips on cutting freezer costs",
},
{
key: "allocation",
prose: (
<>
You’re heavily invested in <Entity name="Vanilla" color="#f97316" /> — it’s <span className="font-medium text-foreground">72.5%</span> of your case.
</>
),
card: (
<AllocationCard
title="Vanilla allocation"
unit="of case"
segments={[
{ name: "VAN", label: "Vanilla", pct: 72.5, amount: "$51,785", color: "#f97316" },
{ name: "CHOC", label: "Chocolate", pct: 22.8, amount: "$16,278", color: "#6b7280" },
{ name: "MINT", label: "Mint", pct: 4.7, amount: "$3,357", color: "#10b981" },
]}
description="Contribution across current inventory value. Pick a segment to inspect it without moving the card."
/>
),
prompt: "If we look at seasonals, what changes?",
},
]}
/>
</div>
);
}
















