Blocks / Org chart

Org chart

People or units as a hierarchy: cards joined by pixel connectors, folds, selection, keyboard.

import { OrgChart, OrgCardBody, structureOrgLayout } from "@forgeron/ui";
/01 → Default
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>
  );
}
/02 → Detailed and folded
Camille RoyChief executiveParis6 under them
Hugo BernardCTOEngineering2 under themHiring
Léa MartinBackend leadEngineering
Senior engineerVacant
Use the arrows, + and −
// 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
PropTypeDefaultDescription
rootsOrgPerson[]—{ 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 / onCollapsedChangestring[]—The cards whose reports are folded. The button at the foot of a card, or − and +.
selected / defaultSelected / onSelectedChangestring | 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.
labelstring"Organisation chart"Names the tree. Arrows walk it: down to the first report, up, sideways along the row.
classNamestring—Extra classes.