Blocks / Approval chain

Approval chain

An approval as steps: people one by one or all at once, status, due date, reminder, comments, audit.

import { ApprovalChain, ApprovalAudit, resolveChain, chainStatus, chainProgress } from "@forgeron/ui";
/01 → Default
To act1 of 4 done
  1. Manager

    ApprovedDue Nov 14
    1. Léa MartinTeam lead2026-11-13 09:12 UTCApproved

    • Léa Martin · 2026-11-13 09:12 UTCFine for me, receipts attached.
  2. Finance

    To actAll at onceDue Nov 18 · late
    1. Karim AzizControllerTo act
    2. Jo BernardAccountingTo act

  3. Director

    Waiting
    1. Sam RocheDirectorWaiting

History

  1. Léa Martin approved
  2. Sam submitted the expense

import { ApprovalChain, type ApprovalStep } from "@forgeron/ui";

const steps: ApprovalStep[] = [
  {
    id: "manager",
    label: "Manager",
    due: "2026-11-14",
    participants: [
      {
        id: "lea",
        name: "Léa Martin",
        role: "Team lead",
        status: "approved",
        at: "2026-11-13T09:12:00Z",
      },
    ],
    comments: [
      {
        id: "c1",
        author: "Léa Martin",
        at: "2026-11-13T09:12:00Z",
        text: "Fine for me, receipts attached.",
      },
    ],
  },
  {
    id: "finance",
    label: "Finance",
    mode: "parallel",
    due: "2026-11-18",
    participants: [
      { id: "karim", name: "Karim Aziz", role: "Controller", reminded: "2026-11-17" },
      { id: "jo", name: "Jo Bernard", role: "Accounting" },
    ],
  },
  {
    id: "director",
    label: "Director",
    participants: [{ id: "sam", name: "Sam Roche", role: "Director" }],
  },
];

export default function Default() {
  return (
    <div style={{ width: "100%", maxWidth: 640 }}>
      <ApprovalChain
        label="Expense 214"
        value={steps}
        today="2026-11-19"
        onRemind={() => {}}
        events={[
          {
            id: "e1",
            at: "2026-11-12T16:40:00Z",
            actor: "Sam",
            action: "submitted the expense",
            tone: "neutral",
          },
          {
            id: "e2",
            at: "2026-11-13T09:12:00Z",
            actor: "Léa Martin",
            action: "approved",
            tone: "success",
          },
        ]}
      />
    </div>
  );
}
/02 → Editable
To act0 of 2 done
  1. Review

    To act
    1. Léa MartinTeam leadTo act
    2. Karim AzizControllerWaiting

import { ApprovalChain, type ApprovalStep } from "@forgeron/ui";
import { useState } from "react";

const people = [
  { id: "lea", name: "Léa Martin", role: "Team lead" },
  { id: "karim", name: "Karim Aziz", role: "Controller" },
  { id: "jo", name: "Jo Bernard", role: "Accounting" },
  { id: "sam", name: "Sam Roche", role: "Director" },
];

export default function Editable() {
  const [steps, setSteps] = useState<ApprovalStep[]>([
    { id: "s1", label: "Review", participants: [people[0]!, people[1]!] },
  ]);
  return (
    <div style={{ width: "100%", maxWidth: 640 }}>
      <ApprovalChain
        label="Approval flow"
        editable
        people={people}
        value={steps}
        onChange={setSteps}
        onComment={() => {}}
      />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
labelstring—Names the chain: “Expense 214”.
value / defaultValue / onChange{ id, label?, mode?, participants, due?, comments? }[]—The steps. mode: sequential (default) or parallel. A participant's status is found (resolveChain) unless given.
editablebooleanfalseAdd, remove and reorder people (drag or Alt + arrows), switch a step's mode, add, move and remove steps.
people{ id, name, role?, email? }[]—Who can be added; those already in the chain are left out.
todaystring—YYYY-MM-DD: a step past its due date is marked late.
onRemind(person, step) => void—The Remind button on whoever is current.
onComment(stepId, text) => void—A box to comment under each step (⌘ Enter sends).
events{ id, at, actor, action, detail?, tone? }[]—The audit, under the chain (newest first). ApprovalAudit alone takes the same.
stepName / stepActions / emptystring; (step, i) => ReactNode; ReactNode—Wording and extras.
statusLabelsPartial<Record<ApprovalStatus, string>>—Other words for waiting, current, approved, rejected, skipped.
classNamestring—Extra classes.