---
title: Diagram components
description: Static diagrams you can edit directly in MDX.
---

Wrap each example in `Diagram` to give it a canvas and an optional caption. Text in a node wraps. On a narrow canvas (under 560px), a `Flow` turns vertical and a `Fan` puts its source above its targets. The components are available in MDX without imports.

## Fan

Put the source node in the `from` slot and list the target nodes in branch order. `Fan` numbers the branches from top to bottom. A node accepts a title, an optional subtitle and icon glyph, and a `tone` of `default`, `accent`, or `muted`. Use `Check` for each checklist row.

<Diagram caption="A successful mutation commits before its events are delivered.">
  <Fan>
    <Node slot="from" title="Caller" subtitle="Runs a mutation" icon="›_" />
    <Node title="Transaction" icon="▤" tone="accent">
      <Check>Policy passed</Check>
      <Check>Input is valid</Check>
      <Check>One commit</Check>
    </Node>
    <Node title="Events" icon="↗">
      <Check>Sent after commit</Check>
    </Node>
  </Fan>
</Diagram>

```mdx
<Diagram caption="A successful mutation commits before its events are delivered.">
  <Fan>
    <Node slot="from" title="Caller" subtitle="Runs a mutation" icon="›_" />
    <Node title="Transaction" icon="▤" tone="accent">
      <Check>Policy passed</Check>
      <Check>Input is valid</Check>
      <Check>One commit</Check>
    </Node>
    <Node title="Events" icon="↗">
      <Check>Sent after commit</Check>
    </Node>
  </Fan>
</Diagram>
```

## Flow and Group

`Flow` adds arrows between adjacent items. Insert `Arrow` between two items to add a number, a label, or both. `Group` puts a labelled outline around a flow, a stack, or a column of nodes.

<Diagram caption="A release moves from draft through review to ready.">
  <Group label="Release">
    <Flow>
      <Node title="Draft" tone="muted" />
      <Arrow n={1} label="submit" />
      <Node title="Review" />
      <Node title="Ready" tone="accent" />
    </Flow>
  </Group>
</Diagram>

```mdx
<Diagram caption="A release moves from draft through review to ready.">
  <Group label="Release">
    <Flow>
      <Node title="Draft" tone="muted" />
      <Arrow n={1} label="submit" />
      <Node title="Review" />
      <Node title="Ready" tone="accent" />
    </Flow>
  </Group>
</Diagram>
```

## Stack

`Stack` puts its children in a column and adds down arrows between them.

<Diagram>
  <Stack>
    <Node title="Write" />
    <Node title="Review" />
    <Node title="Publish" />
  </Stack>
</Diagram>

```mdx
<Diagram>
  <Stack>
    <Node title="Write" />
    <Node title="Review" />
    <Node title="Publish" />
  </Stack>
</Diagram>
```

## Type-checked code

A `ts twoslash` fence checks the snippet against the workspace SDK and shows inferred types on hover. Hover a name to see its type. Don't pin types with `^?`: the popup covers the text below it.

```ts twoslash
import { init } from "logic-sdk";
import { z } from "zod";

const { query } = init<{ scope: { actor: string | null } }>();
export const ping = query({
  input: z.object({ name: z.string() }),
  handler: async (_ctx, { name }) => `hi ${name}`,
});
```

## Generated from the source

<AutoTypeTable path="../../packages/logic-sdk/src/core/types.ts" name="RegistryOptions" />
