Org chart
People or units as a hierarchy: cards joined by pixel connectors, folds, selection, keyboard.
import { OrgChart, OrgCardBody, structureOrgLayout } from "@forgeron/ui";Camille RoyChief executive
Hugo BernardCTO
Léa MartinBackend lead
Noah PetitFrontend lead
Platform engineerVacant
Inès GarciaCOO
Sam DupontOperations
Maya LopezCFO
import { OrgChart, type OrgPerson } from "@forgeron/ui";
export const team: OrgPerson[] = [
{
id: "ceo",
name: "Camille Roy",
title: "Chief executive",
children: [
{
id: "cto",
name: "Hugo Bernard",
title: "CTO",
children: [
{ id: "be", name: "Léa Martin", title: "Backend lead" },
{ id: "fe", name: "Noah Petit", title: "Frontend lead" },
{ id: "open", name: "Platform", title: "Platform engineer", vacant: true },
],
},
{
id: "coo",
name: "Inès Garcia",
title: "COO",
children: [{ id: "ops", name: "Sam Dupont", title: "Operations" }],
},
{ id: "cfo", name: "Maya Lopez", title: "CFO" },
],
},
];
export default function Default() {
return (
<div style={{ width: "100%" }}>
<OrgChart roots={team} defaultSelected="cto" />
</div>
);
}Camille RoyChief executive
Hugo BernardCTOHiring
Léa MartinBackend lead
Senior engineerVacant
Inès GarciaCOO
// The detailed card, with a team line and a badge; the COO's branch starts folded.
import { Badge, OrgChart, type OrgPerson } from "@forgeron/ui";
import { useState } from "react";
const team: OrgPerson[] = [
{
id: "ceo",
name: "Camille Roy",
title: "Chief executive",
meta: "Paris",
children: [
{
id: "cto",
name: "Hugo Bernard",
title: "CTO",
meta: "Engineering",
badge: <Badge tone="success">Hiring</Badge>,
children: [
{ id: "be", name: "Léa Martin", title: "Backend lead", meta: "Engineering" },
{ id: "dev", name: "Backend", title: "Senior engineer", vacant: true },
],
},
{
id: "coo",
name: "Inès Garcia",
title: "COO",
meta: "Operations",
children: [
{ id: "ops", name: "Sam Dupont", title: "Operations", meta: "Operations" },
{ id: "cs", name: "Zoé Faure", title: "Support", meta: "Operations" },
],
},
],
},
];
export default function DetailedAndFolded() {
const [picked, setPicked] = useState<string | null>(null);
return (
<div style={{ display: "grid", gap: 8, width: "100%" }}>
<OrgChart
roots={team}
variant="detailed"
defaultCollapsed={["coo"]}
selected={picked}
onSelectedChange={setPicked}
/>
<span style={{ color: "var(--ink-dim)", font: "400 11px/16px var(--font-mono)" }}>
{picked ? `Selected: ${picked}` : "Use the arrows, + and −"}
</span>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
roots | OrgPerson[] | — | { id, name, title?, meta?, avatar?, vacant?, badge?, children? }. Several roots sit side by side. vacant: a dashed card that says Vacant, name is the label of the post. |
variant | "compact" | "detailed" | "compact" | Avatar, name and role; or more room with the team and the count. |
collapsed / defaultCollapsed / onCollapsedChange | string[] | — | The cards whose reports are folded. The button at the foot of a card, or − and +. |
selected / defaultSelected / onSelectedChange | string | null | — | The picked card. |
onActivate | (id) => void | — | Enter or a double click. |
renderCard | (person, state) => ReactNode | — | Your own card inside the frame; OrgCardBody is the default one. |
label | string | "Organisation chart" | Names the tree. Arrows walk it: down to the first report, up, sideways along the row. |
className | string | — | Extra classes. |