Page recipes
How to combine components for common page types (dashboards, lists, long forms, settings, result pages) following ant-design-pro layouts, plus the old prop names to replace.
Each recipe is the order of blocks from top to bottom. Pick the recipe closest to the page you need, then replace the data and text with your app’s business. The example below is a store owner’s dashboard built from the first recipe.
// Owner dashboard for a 3-channel furniture store: the period picker (today / 7 days / month / 12 months) drives every number; 4 KPIs vs the previous period, revenue vs gross profit chart, channel mix, best sellers, action items and low-stock alerts.
// In a real app: api.reports.summary({ period }) returns the KPIs + daily/monthly series; api.tasks.counts() and api.inventory.lowStock() replace the sample data.
import { useMemo, useState } from "react";
import { PageContainer, ProCard, StatisticCard } from "@ant-design/pro-components";
import { Badge, Button, Col, Flex, Progress, Row, Segmented, Table, Tooltip, Typography, theme, type TableProps } from "antd";
import { ArrowDownOutlined, ArrowUpOutlined, ClockCircleOutlined, DollarOutlined, DownloadOutlined, InboxOutlined, RightOutlined, CarOutlined } from "@ant-design/icons";
import { Column, Pie, Tiny } from "@ant-design/charts";
import dayjs, { type Dayjs } from "dayjs";
type Period = "today" | "7d" | "month" | "12m";
type Day = { date: Dayjs; rev: number[]; gp: number[]; orders: number[] };
const NOW = dayjs("2026-11-13T14:30:00");
const TODAY_SHARE = 0.58; // share of a typical day's revenue taken by 2:30 PM
const CHANNELS = [{ label: "Showroom", aov: 1460, margin: 0.41 }, { label: "Website", aov: 730, margin: 0.35 }, { label: "B2B projects", aov: 0, margin: 0.27 }];
const nf = new Intl.NumberFormat("en-US");
const vnd = (n: number) => `$${nf.format(Math.round(n))}`;
const num = (n: number, d: number) => new Intl.NumberFormat("en-US", { maximumFractionDigits: d }).format(n);
const short = (n: number) => (Math.abs(n) >= 1e6 ? `$${num(n / 1e6, 2)}M` : `$${num(n / 1e3, Math.abs(n) >= 1e5 ? 0 : 1)}k`);
const pct = (x: number) => `${new Intl.NumberFormat("en-US", { minimumFractionDigits: 1, maximumFractionDigits: 1 }).format(x * 100)}%`;
const sum = (a: number[]) => a.reduce((s, v) => s + v, 0);
// Sample data: 731 days of sales generated from a fixed seed (mulberry32) — same result on every render.
function rng(seed: number) {
return () => { seed = (seed + 0x6d2b79f5) | 0; let t = Math.imul(seed ^ (seed >>> 15), 1 | seed); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
}
const DAYS: Day[] = (() => {
const r = rng(2026);
const round = (v: number) => Math.round(v / 10) * 10;
return Array.from({ length: 731 }, (_, i) => {
const date = NOW.startOf("day").subtract(730 - i, "day");
const k = (0.8 + (0.2 * i) / 730) * (i === 730 ? TODAY_SHARE : 1);
const weekend = date.day() === 0 || date.day() === 6 ? 1.55 : 1;
const rev = [round(7600 * k * weekend * (0.75 + 0.5 * r())), round(3500 * k * (0.7 + 0.6 * r())), r() < 0.22 ? round((9.5 + 35 * r()) * 1e3 * k) : 0];
const gp = rev.map((v, c) => round(v * (CHANNELS[c].margin + (r() - 0.5) * 0.04)));
const orders = [Math.max(1, Math.round(rev[0] / CHANNELS[0].aov)), Math.max(1, Math.round(rev[1] / CHANNELS[1].aov)), rev[2] ? 1 : 0];
return { date, rev, gp, orders };
});
})();
const between = (a: Dayjs, b: Dayjs) => DAYS.filter((d) => !d.date.isBefore(a, "day") && !d.date.isAfter(b, "day"));
const scale = (d: Day, k: number): Day => ({ ...d, rev: d.rev.map((v) => v * k), gp: d.gp.map((v) => v * k), orders: d.orders.map((v) => Math.round(v * k)) });
const total = (days: Day[]) => ({
rev: [0, 1, 2].map((c) => sum(days.map((d) => d.rev[c]))),
gp: [0, 1, 2].map((c) => sum(days.map((d) => d.gp[c]))),
orders: [0, 1, 2].map((c) => sum(days.map((d) => d.orders[c]))),
});
const HOURS = [8, 9, 10, 11, 12, 13, 14];
const HOUR_W = [0.06, 0.12, 0.16, 0.18, 0.14, 0.17, 0.17];
function buildPeriod(p: Period) {
const t = NOW.startOf("day");
const [cur, prev, prevLabel] =
p === "today" ? [between(t, t), between(t.subtract(1, "day"), t.subtract(1, "day")).map((d) => scale(d, TODAY_SHARE)), "same time yesterday"]
: p === "7d" ? [between(t.subtract(6, "day"), t), between(t.subtract(13, "day"), t.subtract(7, "day")), "the previous 7 days"]
: p === "month" ? [between(t.startOf("month"), t), between(t.subtract(1, "month").startOf("month"), t.subtract(1, "month")), `the same days of ${t.subtract(1, "month").format("MMMM")}`]
: [between(t.subtract(11, "month").startOf("month"), t), between(t.subtract(23, "month").startOf("month"), t.subtract(12, "month")), "the previous 12 months"];
// Chart columns: by hour (today), by day (7 days, this month), by month (12 months).
const groups = new Map<string, Day[]>();
if (p === "today") HOURS.forEach((h, i) => groups.set(h > 12 ? `${h - 12} PM` : h === 12 ? "12 PM" : `${h} AM`, [scale(cur[0], HOUR_W[i])]));
else cur.forEach((d) => { const key = d.date.format(p === "12m" ? "MMM YY" : "MMM D"); groups.set(key, [...(groups.get(key) ?? []), d]); });
const buckets = [...groups].map(([label, days]) => ({ label, ...total(days) }));
// Open orders: orders from the period not yet delivered, split by order age.
const status = [0, 0, 0];
cur.forEach((d) => {
const age = t.diff(d.date, "day");
d.orders.forEach((n, c) => {
const open = Math.round(n * (age === 0 ? 0.9 : age <= 6 ? 0.55 : age <= 20 ? 0.18 : c === 2 && age <= 60 ? 0.4 : 0));
status[age === 0 ? 0 : age <= 6 ? 1 : 2] += open;
});
});
return { cur: total(cur), prev: total(prev), prevLabel, buckets, status };
}
const PRODUCTS = [
{ name: "Milano 3-seat leather sofa", price: 3490, share: [0.16, 0.08, 0.02] },
{ name: "Oslo oak dining set, 6 chairs", price: 2190, share: [0.12, 0.07, 0.03] },
{ name: "Kyoto walnut bed, king", price: 2690, share: [0.11, 0.06, 0.02] },
{ name: "ErgoPro ergonomic chair", price: 649, share: [0.03, 0.12, 0.1] },
{ name: "Flex 55\" standing desk", price: 899, share: [0.03, 0.09, 0.14] },
{ name: "Mesh office chair", price: 329, share: [0.01, 0.04, 0.22] },
{ name: "Nordic 4-door wardrobe", price: 1590, share: [0.08, 0.05, 0.04] },
];
type Stock = { sku: string; name: string; warehouse: string; onHand: number; min: number; incoming: number; eta?: string; perDay: number };
const STOCK: Stock[] = [
{ sku: "SF-MIL3-GR", name: "Milano 3-seat leather sofa · grey", warehouse: "Austin showroom", onHand: 0, min: 3, incoming: 4, eta: "Nov 25", perDay: 0.4 },
{ sku: "GVP-MESH-BK", name: "Mesh office chair · black", warehouse: "Round Rock warehouse", onHand: 18, min: 60, incoming: 120, eta: "Nov 20", perDay: 7.5 },
{ sku: "BNH-FLX14-WH", name: "Flex 55\" standing desk · white", warehouse: "Round Rock warehouse", onHand: 6, min: 15, incoming: 0, perDay: 1.6 },
{ sku: "GCT-ERGO-BK", name: "ErgoPro ergonomic chair", warehouse: "Round Rock warehouse", onHand: 9, min: 20, incoming: 40, eta: "Nov 18", perDay: 2.1 },
{ sku: "KTV-WAL20", name: "Walnut TV console, 79\"", warehouse: "Austin showroom", onHand: 4, min: 5, incoming: 0, perDay: 0.3 },
];
const DEBTS = [29_500, 22_600, 13_300]; // 3 B2B customers past their payment due date
const STATUS_LABELS = ["Awaiting confirmation", "Being prepared", "Out for delivery & install"];
export default function Page() {
const { token } = theme.useToken();
const [period, setPeriod] = useState<Period>("month");
const d = useMemo(() => buildPeriod(period), [period]);
const rev = sum(d.cur.rev), prevRev = sum(d.prev.rev), gp = sum(d.cur.gp), prevGp = sum(d.prev.gp);
const orders = sum(d.cur.orders), prevOrders = sum(d.prev.orders);
const margin = gp / rev, prevMargin = prevGp / prevRev;
const open = sum(d.status);
const chColors = [token.colorPrimary, token.cyan, token.gold];
const stColors = [token.colorWarning, token.colorPrimary, token.colorSuccess];
const unit = period === "today" ? "hour" : period === "12m" ? "month" : "day";
const delta = (x: number, text: string) => (
<Typography.Text style={{ color: x >= 0 ? token.colorSuccess : token.colorError }}>
{x >= 0 ? <ArrowUpOutlined /> : <ArrowDownOutlined />} {text} <Typography.Text type="secondary">vs {d.prevLabel}</Typography.Text>
</Typography.Text>
);
const spark = (data: number[]) => (
<Tiny.Area height={44} data={data.map((value, index) => ({ index, value }))} xField="index" yField="value" shapeField="smooth"
style={{ fill: token.colorPrimary, fillOpacity: 0.18 }} />
);
const top = PRODUCTS.map((p) => {
const value = sum(p.share.map((s, c) => s * d.cur.rev[c]));
return { ...p, value, units: Math.max(1, Math.round(value / p.price)) };
}).sort((a, b) => b.value - a.value).slice(0, 6);
const tasks = [
{ icon: <ClockCircleOutlined />, title: "Orders unconfirmed for over 2 hours", note: "Oldest 5 h 10 min · 3 website orders", count: 4, color: token.colorWarning },
{ icon: <CarOutlined />, title: "Late deliveries", note: "2 showroom orders · 1 B2B project", count: 3, color: token.colorError },
{ icon: <InboxOutlined />, title: "Items below minimum stock", note: `${STOCK.filter((s) => s.onHand === 0).length} SKU out of stock`, count: STOCK.length, color: token.colorWarning },
{ icon: <DollarOutlined />, title: "Overdue B2B invoices", note: `${vnd(sum(DEBTS))} · oldest 34 days overdue`, count: DEBTS.length, color: token.colorError },
];
const stockCols: TableProps<Stock>["columns"] = [
{ title: "Product", dataIndex: "name", render: (_, r) => <Flex vertical><Typography.Link>{r.name}</Typography.Link><Typography.Text type="secondary" style={{ fontSize: 12 }}>{r.sku} · {r.warehouse}</Typography.Text></Flex> },
{ title: "Status", key: "st", width: 140, render: (_, r) => <Badge status={r.onHand === 0 ? "error" : "warning"} text={r.onHand === 0 ? "Out of stock" : "Below minimum"} /> },
{ title: "On hand / min", key: "qty", align: "right", width: 130, render: (_, r) => <span><b>{r.onHand}</b> / {r.min}</span> },
{ title: "Cover", key: "days", align: "right", width: 100, render: (_, r) => (r.onHand === 0 ? "—" : `${Math.floor(r.onHand / r.perDay)} days`) },
{ title: "Incoming", key: "in", width: 150, render: (_, r) => (r.incoming ? `${r.incoming} units · ${r.eta}` : <Typography.Text type="danger">Not ordered</Typography.Text>) },
{ title: "", key: "act", width: 130, align: "right", render: (_, r) => <Button size="small">{r.incoming ? "View PO" : "Create PO"}</Button> },
];
return (
<PageContainer
title="Good afternoon, Tom"
subTitle={`Oak & Anchor Home · figures as of ${NOW.format("h:mm A")}, Friday ${NOW.format("MMM D, YYYY")}`}
extra={[
<Segmented<Period> key="p" value={period} onChange={setPeriod}
options={[{ label: "Today", value: "today" }, { label: "7 days", value: "7d" }, { label: "This month", value: "month" }, { label: "12 months", value: "12m" }]} />,
<Button key="x" icon={<DownloadOutlined />}>Export report</Button>,
]}
>
<Flex vertical gap={16}>
<Row gutter={[16, 16]}>
<Col xs={24} sm={12} xl={6}>
<StatisticCard style={{ height: "100%" }} chart={spark(d.buckets.map((b) => sum(b.rev)))}
statistic={{ title: "Revenue", value: rev, formatter: () => <Tooltip title={vnd(rev)}>{short(rev)}</Tooltip>, description: delta(rev / prevRev - 1, pct(Math.abs(rev / prevRev - 1))) }}
footer={<Typography.Text type="secondary">Gross profit {short(gp)}</Typography.Text>} />
</Col>
<Col xs={24} sm={12} xl={6}>
<StatisticCard style={{ height: "100%" }} chart={spark(d.buckets.map((b) => sum(b.orders)))}
statistic={{ title: "New orders", value: orders, formatter: () => nf.format(orders), description: delta(orders / prevOrders - 1, pct(Math.abs(orders / prevOrders - 1))) }}
footer={<Typography.Text type="secondary">Average order {short(rev / Math.max(1, orders))}</Typography.Text>} />
</Col>
<Col xs={24} sm={12} xl={6}>
<StatisticCard style={{ height: "100%" }} chart={spark(d.buckets.map((b) => sum(b.gp) / Math.max(1, sum(b.rev))))}
statistic={{ title: "Gross margin", value: margin, formatter: () => pct(margin), description: delta(margin - prevMargin, `${num(Math.abs(margin - prevMargin) * 100, 1)} pts`) }}
footer={<Typography.Text type="secondary">Lowest, B2B: {pct(d.cur.gp[2] / Math.max(1, d.cur.rev[2]))}</Typography.Text>} />
</Col>
<Col xs={24} sm={12} xl={6}>
<StatisticCard style={{ height: "100%" }}
statistic={{ title: "Open orders", value: open, formatter: () => nf.format(open), description: <Typography.Text type="secondary">of {nf.format(orders)} orders this period</Typography.Text> }}
chart={
<Flex vertical gap={8} style={{ paddingTop: 8 }}>
<Flex style={{ height: 10, borderRadius: 5, overflow: "hidden", background: token.colorFillSecondary }}>
{d.status.map((n, i) => <Tooltip key={i} title={`${STATUS_LABELS[i]}: ${n}`}><div style={{ width: `${(n / Math.max(1, open)) * 100}%`, background: stColors[i] }} /></Tooltip>)}
</Flex>
{d.status.map((n, i) => (
<Flex key={i} justify="space-between" style={{ fontSize: 12 }}>
<Badge color={stColors[i]} text={STATUS_LABELS[i]} /><b>{n}</b>
</Flex>
))}
</Flex>
} />
</Col>
</Row>
<Row gutter={[16, 16]}>
<Col xs={24} lg={15}>
<ProCard title="Revenue and gross profit" subTitle={`by ${unit}`} headerBordered style={{ height: "100%" }}>
<Column height={300} data={d.buckets.flatMap((b) => [{ label: b.label, kind: "Revenue", value: sum(b.rev) }, { label: b.label, kind: "Gross profit", value: sum(b.gp) }])}
xField="label" yField="value" colorField="kind" group
scale={{ color: { range: [token.colorPrimary, token.colorSuccess] } }}
axis={{ y: { labelFormatter: (v: number) => short(v) } }}
legend={{ color: { position: "top", layout: { justifyContent: "flex-end" } } }}
tooltip={{ items: [{ channel: "y", valueFormatter: (v: number) => vnd(v) }] }} />
</ProCard>
</Col>
<Col xs={24} lg={9}>
<ProCard title="Needs attention" subTitle="updated 2:30 PM" headerBordered style={{ height: "100%" }} bodyStyle={{ padding: 8 }}>
<Flex vertical>
{tasks.map((t) => (
<a key={t.title} href="#" onClick={(e) => e.preventDefault()}
style={{ display: "flex", alignItems: "center", gap: 12, padding: "12px 12px", borderRadius: token.borderRadius, color: token.colorText, borderBottom: `1px solid ${token.colorSplit}` }}>
<span style={{ color: t.color, fontSize: 18 }}>{t.icon}</span>
<Flex vertical style={{ flex: 1, minWidth: 0 }}>
<Typography.Text strong>{t.title}</Typography.Text>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>{t.note}</Typography.Text>
</Flex>
<Typography.Text strong style={{ fontSize: 20, color: t.color }}>{t.count}</Typography.Text>
<RightOutlined style={{ color: token.colorTextTertiary }} />
</a>
))}
</Flex>
</ProCard>
</Col>
</Row>
<Row gutter={[16, 16]}>
<Col xs={24} lg={10}>
<ProCard title="Revenue by channel" subTitle={`total ${vnd(rev)}`} headerBordered style={{ height: "100%" }}>
<Pie height={220} data={CHANNELS.map((c, i) => ({ type: c.label, value: d.cur.rev[i] }))} angleField="value" colorField="type"
innerRadius={0.66} label={false} legend={false} scale={{ color: { range: chColors } }}
tooltip={{ items: [{ field: "value", valueFormatter: (v: number) => vnd(v) }] }}
annotations={[{ type: "text", style: { text: short(rev), x: "50%", y: "50%", textAlign: "center", fontSize: 18, fontWeight: 600 } }]} />
<Flex vertical gap={8}>
{CHANNELS.map((c, i) => (
<Flex key={c.label} justify="space-between" gap={8}>
<Badge color={chColors[i]} text={c.label} />
<Typography.Text type="secondary">{nf.format(d.cur.orders[i])} orders</Typography.Text>
<span><b>{short(d.cur.rev[i])}</b> <Typography.Text type="secondary">· {pct(d.cur.rev[i] / rev)}</Typography.Text></span>
</Flex>
))}
</Flex>
</ProCard>
</Col>
<Col xs={24} lg={14}>
<ProCard title="Best sellers" subTitle="by revenue" extra={<a>View product report</a>} headerBordered style={{ height: "100%" }}>
<Flex vertical gap={12}>
{top.map((p, i) => (
<Flex key={p.name} align="center" gap={12}>
<Typography.Text strong style={{ width: 20, color: i < 3 ? token.colorPrimary : token.colorTextTertiary }}>{i + 1}</Typography.Text>
<Flex vertical style={{ flex: 1, minWidth: 0 }}>
<Flex justify="space-between" gap={8}>
<Typography.Text ellipsis>{p.name}</Typography.Text>
<Typography.Text strong>{short(p.value)}</Typography.Text>
</Flex>
<Flex align="center" gap={8}>
<Progress percent={(p.value / top[0].value) * 100} showInfo={false} size="small" style={{ flex: 1, margin: 0 }} />
<Typography.Text type="secondary" style={{ fontSize: 12, width: 64, textAlign: "right" }}>{nf.format(p.units)} units</Typography.Text>
</Flex>
</Flex>
</Flex>
))}
</Flex>
</ProCard>
</Col>
</Row>
<ProCard title="Low stock" subTitle={`${STOCK.length} SKUs below minimum stock`} extra={<a>Open inventory</a>} headerBordered bodyStyle={{ paddingTop: 0 }}>
<Table<Stock> rowKey="sku" size="small" columns={stockCols} dataSource={STOCK} pagination={false} scroll={{ x: 760 }} />
</ProCard>
</Flex>
</PageContainer>
);
}
Build a daily executive dashboard for the owner of a furniture chain that sells on 3 channels (showroom, website, B2B projects). At the top: a greeting with the data timestamp and a period picker Today / 7 days / This month / 12 months; changing the period changes every number and compares it with the matching previous period (yesterday at the same hour, the same days last month…). First row: 4 KPI cards with sparklines — revenue, new orders, gross margin (change shown in percentage points), and orders in progress with a bar stacked by status. Next: a column chart of revenue and gross profit by hour/day/month, and beside it a "To do" panel where every row is clickable and shows a count — orders waiting for confirmation over 2 hours, late deliveries, items below minimum stock and overdue B2B receivables. Add a donut of revenue by channel (the channels must add up to total revenue), a "Best sellers" list with progress bars, and a low-stock table with a button to create a purchase order. Format money for the app's locale. Every number comes from the app's API through useApiClient() (period report, to-do counts, low-stock list) — no hard-coded data.
Approver dashboard
Approvers open the app to see how much work is waiting. Their to-do list comes first, figures come after.
PageContainer greeting + number of pending items
└── StatRow 3 figures, each with a secondary line
└── Row gutter
├── Col lg={15} ProList: items to approve
└── Col lg={9} breakdown chartAnalysis dashboard
Business owners review trends by period and compare groups.
Row 4 KPI cards: big number + small chart + footer metric
Tabbed card sales / visits, date presets in tabBarExtraContent
├── Col xl={16} column chart
└── Col xl={8} ranking list
Row 2 half-width cards: top list, pie chart with SegmentedList page
PageContainer → ProTable (search fields, tabs with counts, a create button in toolBarRender, rowSelection with bulk actions). Clicking a row opens the detail page, or a Drawer size={600} with ProDescriptions for records with few fields. Details in List pages.
Card list
Product catalogs and projects: ProList grid={{ gutter: 16, column: 3 }} with metas: title, subTitle (Tag), avatar, description, content (progress), actions.
Long form with sections
ProForm wraps all PageContainer content
├── ProCard one card per section, 3 fields per row
├── EditableProTable line items
└── FooterToolbar submit button + error listStep form
PageContainer → ProCard → StepsForm: fill in → confirm (Descriptions + Alert) → Result status="success". See Forms.
Settings page
Two columns: on the left, a 224px Menu mode="inline" lists the sections; on the right, a ProForm layout="vertical" for the selected section, with a save button only.
<Flex gap={24}>
<Menu mode="inline" style={{ width: 224 }} selectedKeys={[section]}
onClick={(e) => setSection(e.key)} items={SECTIONS} />
<ProForm layout="vertical" style={{ flex: 1 }} key={section}
request={() => api.settings.list()}
submitter={{ searchConfig: { submitText: "Save" }, resetButtonProps: false }}
onFinish={async (v) => { await api.settings.put(v); message.success("Saved"); return true; }}>
{/* … fields of the selected section */}
</ProForm>
</Flex>Result and error pages
Result status="success" | "error" | "403" | "404" | "500" with one primary button, such as Back to list. Put it inside PageContainer so the user still sees the menu.
Old names to replace
Examples on the web often use old prop names. Use the name on the right of the arrow:
- antd
Card:bordered→variant;bodyStyle/headStyle→styles={{ body, header }}.ProCardandStatisticCard2.x still usebodyStyle/bordered, so both names are correct there. Modal/Drawer:visible→open;destroyOnClose→destroyOnHidden(see the reset note in Forms);Drawerwidth→size.Tabs.TabPane/Menu.Itemwritten as JSX → theitemsprop.Space direction→orientation,split→separator.Steps direction→orientation,items.description→items.content.Statistic valueStyle→styles.content.Alert message→title.Dropdown.Button/Button.Group→Space.Compact.- pro-components v3 names don’t exist in 2.8.10: use
renderFormItem(notformItemRender);layout="mix"is still valid.
Good to know
- Don’t copy
createStyles, less, orclassName={styles.x}from ant-design-pro. Use tokens + inlinestyle,Grid.useBreakpoint()instead of@media, plain strings instead ofuseIntl, anduseNavigateinstead of umi’shistory. - Lay out columns of cards with
Row gutter+Col, notProCard gutter, which insets the cards from the full-width cards above and below. - antd
Listis deprecated as of 6.4. For new card grids, useProListorRow/ColholdingProCard.
Next steps
- Pick a component by job — what the user does → which component to use.
- Dashboards — KPI cards and charts.
- Detail pages — header, approval progress and history.