Diagrams, kanban, AI chat
Screens beyond tables and forms, built with libraries already in your app: edit a process as a diagram, view an org chart, drag cards on a kanban board, chat with AI.
Four libraries ship with the app (@xyflow/react, @ant-design/graphs, @dnd-kit/*, @ant-design/x). Import them directly, no install. Each example is a complete app/page.tsx to copy as a starting point: an approval flow editor, an org chart, an order kanban, an AI assistant.
Shortcut: an AI assistant with its server side (a *.agent.ts file, stored conversations, tools on your app’s real data, every step shown as it happens, changes to data waiting for the user’s approval) comes ready with block_add("ai-assistant"), so ask your agent to add it instead of writing it.
Edit a process as a diagram
When users need to draw or change a process (approval steps, a handling flow), use @xyflow/react: ReactFlow, useNodesState, useEdgesState, addEdge, and custom nodes with Handle.
// Approval workflow designer: @xyflow/react drag-and-drop nodes, connect edges, add steps, save as JSON (CSS ships in the vendor bundle — don't import .css).
import { useCallback, useState } from "react";
import { PageContainer, ProCard } from "@ant-design/pro-components";
import { App, Button, Flex, Input, Select, Space, Tag, theme } from "antd";
import { PlusOutlined, SaveOutlined } from "@ant-design/icons";
import { ReactFlow, Background, Controls, MiniMap, addEdge, useNodesState, useEdgesState, Handle, Position, type Connection, type Node, type Edge } from "@xyflow/react";
type StepData = { label: string; role: string };
const ROLES = [
{ value: "staff", label: "Employee" },
{ value: "manager", label: "Manager" },
{ value: "accountant", label: "Accountant" },
{ value: "director", label: "Director" },
];
function StepNode({ data }: { data: StepData }) {
const { token } = theme.useToken();
return (
<div style={{ padding: "8px 12px", minWidth: 160, borderRadius: token.borderRadiusLG, background: token.colorBgContainer, border: `1px solid ${token.colorBorder}`, boxShadow: token.boxShadowTertiary }}>
<Handle type="target" position={Position.Top} />
<div style={{ fontWeight: 600, color: token.colorText }}>{data.label}</div>
<Tag color="blue" style={{ marginTop: 4 }}>{ROLES.find((r) => r.value === data.role)?.label ?? data.role}</Tag>
<Handle type="source" position={Position.Bottom} />
</div>
);
}
const nodeTypes = { step: StepNode };
const initialNodes: Node<StepData>[] = [
{ id: "1", type: "step", position: { x: 120, y: 0 }, data: { label: "Submit request", role: "staff" } },
{ id: "2", type: "step", position: { x: 120, y: 120 }, data: { label: "Manager approval", role: "manager" } },
{ id: "3", type: "step", position: { x: 0, y: 240 }, data: { label: "Accounting review", role: "accountant" } },
{ id: "4", type: "step", position: { x: 260, y: 240 }, data: { label: "Director approval (> $2,000)", role: "director" } },
];
const initialEdges: Edge[] = [
{ id: "e1-2", source: "1", target: "2", animated: true },
{ id: "e2-3", source: "2", target: "3" },
{ id: "e2-4", source: "2", target: "4", label: "> $2,000" },
];
export default function Page() {
const { message } = App.useApp();
const [nodes, setNodes, onNodesChange] = useNodesState<Node<StepData>>(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState<Edge>(initialEdges);
const [label, setLabel] = useState("");
const [role, setRole] = useState("manager");
const onConnect = useCallback((c: Connection) => setEdges((eds) => addEdge(c, eds)), [setEdges]);
const addStep = () => {
if (!label.trim()) return;
const id = String(Date.now());
setNodes((ns) => [...ns, { id, type: "step", position: { x: 120, y: 360 + ns.length * 10 }, data: { label: label.trim(), role } }]);
setLabel("");
};
return (
<PageContainer
title="Spend request approval flow"
extra={[
<Button key="save" type="primary" icon={<SaveOutlined />} onClick={() => message.success(`Saved ${nodes.length} steps and ${edges.length} links (JSON sent to the API)`)}>
Save workflow
</Button>,
]}
>
<ProCard
title="Diagram"
extra={
<Space.Compact>
<Input placeholder="Step name" value={label} onChange={(e) => setLabel(e.target.value)} onPressEnter={addStep} style={{ width: 200 }} />
<Select value={role} onChange={setRole} options={ROLES} style={{ width: 150 }} />
<Button icon={<PlusOutlined />} onClick={addStep}>
Add step
</Button>
</Space.Compact>
}
>
<Flex style={{ height: 520 }}>
<ReactFlow nodes={nodes} edges={edges} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onConnect={onConnect} nodeTypes={nodeTypes} fitView>
<Background />
<MiniMap pannable zoomable />
<Controls />
</ReactFlow>
</Flex>
</ProCard>
</PageContainer>
);
}
Build the "Workflow designer (React Flow)" screen for my app following the Manh UI playbook (framework_docs("pro")): Approval workflow designer: @xyflow/react drag-and-drop nodes, connect edges, add steps, save as JSON (CSS is in the vendor bundle — do not import .css). Data comes from the app's API through useApiClient(); labels and fields follow my spec.Save the whole diagram as JSON { nodes, edges } through the app’s API.
const [nodes, setNodes, onNodesChange] = useNodesState<Node<StepData>>(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState<Edge>(initialEdges);
const onConnect = useCallback((c: Connection) => setEdges((eds) => addEdge(c, eds)), [setEdges]);
const save = () => api.workflows.update(id, { graph: JSON.stringify({ nodes, edges }) });
<Flex style={{ height: 520 }}> {/* the container needs a fixed height */}
<ReactFlow nodes={nodes} edges={edges} onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange} onConnect={onConnect} nodeTypes={nodeTypes} fitView>
<Background /><MiniMap pannable zoomable /><Controls />
</ReactFlow>
</Flex>Color nodes with theme.useToken() so the diagram follows the app’s light and dark themes.
View an org chart
For view-only diagrams built from data (org charts, flows, mind maps), use @ant-design/graphs: OrganizationChart, FlowGraph, MindMap, FlowDirectionGraph.
// Read-only org chart: @ant-design/graphs OrganizationChart built from department data (G6: { nodes: [{ id, data }], edges }).
import { useMemo, useState } from "react";
import { PageContainer, ProCard } from "@ant-design/pro-components";
import { Segmented } from "antd";
import { OrganizationChart } from "@ant-design/graphs";
const people = [
{ id: "ceo", name: "Sarah Mitchell · CEO", manager: null },
{ id: "cfo", name: "James Porter · CFO", manager: "ceo" },
{ id: "coo", name: "Emily Chen · Operations", manager: "ceo" },
{ id: "sales", name: "David Ross · Sales", manager: "ceo" },
{ id: "acc1", name: "Olivia · Accounting", manager: "cfo" },
{ id: "wh", name: "Ryan · Warehouse", manager: "coo" },
{ id: "ship", name: "Grace · Delivery", manager: "coo" },
{ id: "s1", name: "Kevin · Sales", manager: "sales" },
{ id: "s2", name: "Megan · Sales", manager: "sales" },
];
export default function Page() {
const [direction, setDirection] = useState<"vertical" | "horizontal">("vertical");
const data = useMemo(
() => ({
nodes: people.map((p) => ({ id: p.id, data: { name: p.name } })),
edges: people.filter((p) => p.manager).map((p) => ({ source: p.manager as string, target: p.id })),
}),
[],
);
return (
<PageContainer title="Org chart">
<ProCard
extra={
<Segmented
value={direction}
onChange={(v) => setDirection(v as "vertical" | "horizontal")}
options={[
{ value: "vertical", label: "Vertical" },
{ value: "horizontal", label: "Horizontal" },
]}
/>
}
>
<div style={{ height: 520 }}>
<OrganizationChart key={direction} data={data} direction={direction} labelField={(d: { data?: { name?: string } }) => d.data?.name ?? ""} autoFit="view" />
</div>
</ProCard>
</PageContainer>
);
}
Build the "Org chart (graphs)" screen for my app following the Manh UI playbook (framework_docs("pro")): Read-only org chart: @ant-design/graphs OrganizationChart from department data (G6: { nodes: [{ id, data }], edges }). Data comes from the app's API through useApiClient(); labels and fields follow my spec.const data = {
nodes: people.map((p) => ({ id: p.id, data: { name: p.name } })),
edges: people.filter((p) => p.manager).map((p) => ({ source: p.manager, target: p.id })),
};
<div style={{ height: 520 }}>
<OrganizationChart data={data} labelField={(d) => d.data.name} autoFit="view" />
</div>Drag-and-drop kanban
A kanban board lets users change a stage by dragging a card to another column. Use @dnd-kit/core: DndContext, useDraggable, useDroppable, DragOverlay. Show a column’s status colour as a Badge dot or a Tag next to its name, not as a thick coloured border on top of the column or card.
// Sales pipeline kanban: @dnd-kit drags cards between columns, with a count and total value per column; cards styled with antd tokens.
import { useMemo, useState } from "react";
import { PageContainer } from "@ant-design/pro-components";
import { Avatar, Badge, Card, Flex, Tag, Typography, theme } from "antd";
import { DndContext, DragOverlay, PointerSensor, useDroppable, useDraggable, useSensor, useSensors, type DragEndEvent, type DragStartEvent } from "@dnd-kit/core";
/** Mock people get a face (manh.run avatars 01–24), the same one for the same name. */
const face = (name: string) => {
let h = 0;
for (const ch of name) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
return `https://manh.run/avatars/${String((h % 24) + 1).padStart(2, "0")}.svg`;
};
type Stage = "lead" | "contact" | "quote" | "won";
type Deal = { id: string; name: string; company: string; value: number; owner: string; stage: Stage };
const STAGES: Array<{ key: Stage; title: string; color: string }> = [
{ key: "lead", title: "Lead", color: "default" },
{ key: "contact", title: "Contacted", color: "processing" },
{ key: "quote", title: "Quoted", color: "warning" },
{ key: "won", title: "Won", color: "success" },
];
const DEALS: Deal[] = [
{ id: "d1", name: "Inventory software", company: "Acme Supply Co.", value: 48_000, owner: "Mike", stage: "lead" },
{ id: "d2", name: "CRM plan, 20 seats", company: "Eastgate Group", value: 34_000, owner: "Laura", stage: "contact" },
{ id: "d3", name: "2027 maintenance", company: "Northwind Steel", value: 16_000, owner: "Ben", stage: "quote" },
{ id: "d4", name: "Invoicing integration", company: "Maple Street Cafe", value: 10_000, owner: "Mike", stage: "won" },
{ id: "d5", name: "Sales dashboard", company: "GreenLeaf Market", value: 24_000, owner: "Hannah", stage: "lead" },
];
const vnd = (n: number) => n.toLocaleString("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 });
function DealCard({ deal, dragging }: { deal: Deal; dragging?: boolean }) {
return (
<Card size="small" style={{ cursor: "grab", opacity: dragging ? 0.4 : 1 }}>
<Typography.Text strong>{deal.name}</Typography.Text>
<div style={{ fontSize: 12 }}>
<Typography.Text type="secondary">{deal.company}</Typography.Text>
</div>
<Flex justify="space-between" align="center" style={{ marginTop: 8 }}>
<Typography.Text>{vnd(deal.value)}</Typography.Text>
<Avatar size="small" src={face(deal.owner)} alt={deal.owner} />
</Flex>
</Card>
);
}
function Draggable({ deal }: { deal: Deal }) {
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({ id: deal.id });
return (
<div ref={setNodeRef} {...listeners} {...attributes}>
<DealCard deal={deal} dragging={isDragging} />
</div>
);
}
function Column({ stage, deals }: { stage: (typeof STAGES)[number]; deals: Deal[] }) {
const { token } = theme.useToken();
const { setNodeRef, isOver } = useDroppable({ id: stage.key });
const total = deals.reduce((a, d) => a + d.value, 0);
return (
<div
ref={setNodeRef}
style={{ flex: "1 1 240px", minWidth: 220, background: isOver ? token.colorPrimaryBg : token.colorFillQuaternary, borderRadius: token.borderRadiusLG, padding: token.paddingSM }}
>
<Flex justify="space-between" align="center" style={{ marginBottom: 8 }}>
<Flex gap={6} align="center">
<Tag color={stage.color}>{stage.title}</Tag>
<Badge count={deals.length} showZero color={token.colorTextTertiary} />
</Flex>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>{vnd(total)}</Typography.Text>
</Flex>
<Flex vertical gap={8} style={{ minHeight: 120 }}>
{deals.map((d) => (
<Draggable key={d.id} deal={d} />
))}
</Flex>
</div>
);
}
export default function Page() {
const [deals, setDeals] = useState(DEALS);
const [active, setActive] = useState<string | null>(null);
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
const byStage = useMemo(() => Object.fromEntries(STAGES.map((s) => [s.key, deals.filter((d) => d.stage === s.key)])), [deals]);
const onStart = (e: DragStartEvent) => setActive(String(e.active.id));
const onEnd = (e: DragEndEvent) => {
setActive(null);
const to = e.over?.id as Stage | undefined;
if (!to) return;
// Real app: await api.deals.update(id, { stage: to }) then refresh().
setDeals((ds) => ds.map((d) => (d.id === e.active.id ? { ...d, stage: to } : d)));
};
return (
<PageContainer title="Sales pipeline" subTitle="Drag a card to another column to change its stage">
<DndContext sensors={sensors} onDragStart={onStart} onDragEnd={onEnd}>
<Flex gap={12} wrap align="flex-start">
{STAGES.map((s) => (
<Column key={s.key} stage={s} deals={byStage[s.key]} />
))}
</Flex>
<DragOverlay>{active ? <DealCard deal={deals.find((d) => d.id === active)!} /> : null}</DragOverlay>
</DndContext>
</PageContainer>
);
}
Build the "Drag-and-drop kanban (dnd-kit)" screen for my app following the Manh UI playbook (framework_docs("pro")): Customer pipeline kanban: @dnd-kit drags cards between columns, count and total value per column, ProCard cards on antd tokens. Data comes from the app's API through useApiClient(); labels and fields follow my spec.Save the new stage in onDragEnd, then reload the list.
// A drag starts only after 5px, so clicking a card still opens it
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
const onDragEnd = async (e: DragEndEvent) => {
setActive(null);
const to = e.over?.id as Stage | undefined;
if (!to) return;
await api.deals.update(Number(e.active.id), { stage: to });
refresh();
};
<DndContext sensors={sensors} onDragStart={(e) => setActive(String(e.active.id))} onDragEnd={onDragEnd}>
<Flex gap={12} wrap align="flex-start">
{STAGES.map((s) => <Column key={s.key} stage={s} deals={byStage[s.key]} />)}
</Flex>
<DragOverlay>{active ? <DealCard deal={find(active)} /> : null}</DragOverlay>
</DndContext>To reorder rows in a table, use DragSortTable from pro-components.
AI chat
A chat panel uses @ant-design/x: Welcome and Prompts before the first message, Bubble.List for the conversation, and Sender for the input. Render AI answers with <XMarkdown content> from @ant-design/x-markdown.
// In-app AI assistant: antd X (Welcome, Prompts, Bubble.List, Sender) + XMarkdown; the answer is a simulated stream (real app: the "ai-assistant" lego block).
import { useState } from "react";
import { PageContainer, ProCard } from "@ant-design/pro-components";
import { Flex } from "antd";
import { RobotOutlined, UserOutlined } from "@ant-design/icons";
import { Bubble, Prompts, Sender, Welcome } from "@ant-design/x";
import XMarkdown from "@ant-design/x-markdown";
type Msg = { key: string; role: "user" | "ai"; content: string; loading?: boolean };
const ANSWER = `There are **3 orders past their delivery date**:
| Order | Customer | Late by |
|---|---|---|
| SO-2026-0141 | Acme Supply Co. | 2 days |
| SO-2026-0150 | Maple Street Cafe | 1 day |
| SO-2026-0152 | Northwind Steel | 1 day |
Suggestion: call **Acme Supply** first — it's the largest order ($4,800).`;
export default function Page() {
const [items, setItems] = useState<Msg[]>([]);
const [text, setText] = useState("");
const [busy, setBusy] = useState(false);
const send = (q: string) => {
if (!q.trim() || busy) return;
const key = "a" + Date.now();
setItems((p) => [...p, { key: "u" + Date.now(), role: "user", content: q }, { key, role: "ai", content: "", loading: true }]);
setText("");
setBusy(true);
// Simulated answer (the real block: agent steps over the WebSocket, see block "ai-assistant").
let i = 0;
const timer = setInterval(() => {
i += 6;
setItems((p) => p.map((m) => (m.key === key ? { ...m, loading: false, content: ANSWER.slice(0, i) } : m)));
if (i >= ANSWER.length) {
clearInterval(timer);
setBusy(false);
}
}, 30);
};
return (
<PageContainer title="Assistant">
<ProCard>
<Flex vertical gap={12} style={{ height: 520 }}>
<div style={{ flex: 1, minHeight: 0, overflow: "auto" }}>
{items.length === 0 ? (
<Flex vertical gap={16}>
<Welcome icon={<RobotOutlined style={{ fontSize: 32 }} />} title="Sales assistant" description="Ask about orders, stock or customers — the assistant looks up real data with the app's own tools." />
<Prompts
items={["Which orders are overdue?", "What's about to run out of stock?", "How are sales this week?"].map((d, i) => ({ key: String(i), description: d }))}
onItemClick={(info) => send(String(info.data.description))}
/>
</Flex>
) : (
<Bubble.List
items={items.map((m) => ({
key: m.key,
role: m.role,
placement: m.role === "user" ? "end" : "start",
avatar: m.role === "user" ? <UserOutlined /> : <RobotOutlined />,
loading: m.loading,
content: m.role === "ai" ? <XMarkdown content={m.content} /> : m.content,
}))}
/>
)}
</div>
<Sender value={text} onChange={setText} loading={busy} onSubmit={send} placeholder="Ask the assistant…" />
</Flex>
</ProCard>
</PageContainer>
);
}
Build the "AI assistant (antd X)" screen for my app following the Manh UI playbook (framework_docs("pro")): In-app AI assistant: antd X (Welcome, Prompts, Bubble.List, Sender) + XMarkdown; the answer is a simulated stream (real apps: the "ai-assistant" lego block). Data comes from the app's API through useApiClient(); labels and fields follow my spec.The server side (storing conversations, letting the AI call tools on your app’s data with the user’s own permissions, approval before any change to data, a stop button) comes ready in the ai-assistant block; the example below only simulates the answer. Ask your agent to add the block instead of writing it. The server runs the agent with manh/agent.
Live updates
When someone else changes data (drags a card, approves an order), your screen reloads right away. The handler sends a signal after a successful write; the page listens on that channel.
import { broadcast } from "manh/realtime";
// … after the update succeeds
broadcast("deals", { id: deal.id });import { useLive } from "app/hooks";
useLive("deals", () => refresh());Good to know
- Don’t import the CSS file of
@xyflow/react. The CSS is already included, andcheckreportscode.no-css-import. - The container of
ReactFlowor an@ant-design/graphschart needs a fixed height; otherwise the diagram is 0px tall. - Anyone who opens the app can listen on a realtime channel (except
user:<id>). Send only ids or a “changed” signal, and let the page reload through the API, which checks permissions.
Next steps
- Business screens — a complete order kanban with stage rules.
- Email, AI, file storage — the built-in services your app’s server can call.
- Pick a component by job — when to use a diagram, a kanban or a table.