All blocks
[32] Data
Stat Cards
Four numbers with change badges and trend lines under a period switch, then a list of recent activity.
1280px
Copy the code
One file with one component and its sample data. It needs @vaneui/ui and its stylesheet, set up as in the installation guide.
stat-cards.tsx
import { Avatar, Badge, Card, Col, Container, Grid4, Link, PageTitle, Row, Section, SegmentedControl, SegmentedControlItem, Text, Title } from "@vaneui/ui";
const kpis = [ { label: "Revenue", value: "$48,210", change: "+12.4%", good: true, points: [8, 9, 7, 10, 12, 11, 14, 15] }, { label: "New customers", value: "312", change: "+4.1%", good: true, points: [6, 7, 7, 8, 7, 9, 9, 10] }, { label: "Churn", value: "1.8%", change: "-0.3%", good: true, points: [9, 8, 8, 7, 7, 6, 6, 5] }, { label: "Open tickets", value: "41", change: "+9", good: false, points: [4, 5, 5, 6, 8, 7, 9, 10] },];const feed = [ { who: "Ana Diaz", did: "upgraded", what: "Northwind", to: "to the Team plan", href: "/customers/northwind", when: "12 min ago" }, { who: "Lee Park", did: "refunded", what: "order #1041", to: "", href: "/orders/1041", when: "1h ago" }, { who: "Sam Ortiz", did: "closed", what: "ticket #882", to: "", href: "/tickets/882", when: "3h ago" }, { who: "Mia Chen", did: "invited", what: "2 people", to: "to Support", href: "/team", when: "Yesterday" },];
/** A trend line for a card: decoration, as the number and the change badge carry the meaning */function Sparkline({ points }: { points: number[] }) { const max = Math.max(...points); const min = Math.min(...points); const d = points.map((p, i) => `${(i / (points.length - 1)) * 100},${28 - ((p - min) / (max - min || 1)) * 26}`).join(" "); return ( <svg viewBox="0 0 100 30" preserveAspectRatio="none" className="h-8 w-full" aria-hidden="true"> <polyline points={d} fill="none" stroke="currentColor" strokeWidth="2" vectorEffect="non-scaling-stroke" /> </svg> );}
export function StatCards() { return ( <Section> <Container itemsStretch> <Col lg> <Row justifyBetween flexWrap> <PageTitle>Overview</PageTitle> <SegmentedControl aria-label="Period" defaultValue="30"> <SegmentedControlItem value="7">7 days</SegmentedControlItem> <SegmentedControlItem value="30">30 days</SegmentedControlItem> <SegmentedControlItem value="90">90 days</SegmentedControlItem> </SegmentedControl> </Row> <Grid4 className="max-tablet:grid-cols-2 max-mobile:grid-cols-1"> {kpis.map((k) => ( <Card key={k.label}> <Text sm secondary>{k.label}</Text> <Row justifyBetween itemsBaseline> <Title xl tag="p" className="tabular-nums">{k.value}</Title> <Badge success={k.good} danger={!k.good}>{k.change}</Badge> </Row> <Text tag="div" tertiary wFull><Sparkline points={k.points} /></Text> </Card> ))} </Grid4> <Card> <Row justifyBetween> <Title tag="h2">Recent activity</Title> <Link href="/activity">View all</Link> </Row> <Col noGap> {feed.map((f) => ( <Row key={f.href} justifyBetween borderT paddingY> <Row sm className="min-w-0"> <Avatar sm name={f.who} alt="" /> <Text sm> <Text tag="span" sm fontSemibold>{f.who}</Text> {f.did} <Link href={f.href}>{f.what}</Link> {f.to} </Text> </Row> <Text xs tertiary whitespaceNowrap>{f.when}</Text> </Row> ))} </Col> </Card> </Col> </Container> </Section> );}Components in this block
Adapt it with your coding agent
Add the VaneUI MCP server, and your agent reads the component docs and prop tables while it changes the block: the copy, the sample data or the layout.
$ claude mcp add vaneui -- npx -y @vaneui/mcp
Setup for other editors is in the AI assistants guide.