---
title: "Diagram"
description: "Mermaid diagram source."
---

> Documentation Index
> Fetch the complete documentation index at: https://gistui.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Diagram

```gistui
root = Diagram("flowchart LR\n  Model -->|GistUI Lang| Stream --> Parser --> UI", title:"Pipeline")
```

With Mermaid on the page (`window.mermaid`) the diagram is drawn; otherwise its source is shown.

## Signature

This is the line a model reads in the system prompt.

```gistui
Diagram(source, title:str)
```

- **Group:** Content
- **Children:** No
- **Positional arguments:** `source` (a trailing `?` means it may be left out)

## Props

| Prop | Type | How to write it | Notes |
|---|---|---|---|
| `source` | string | positional, required |  |
| `title` | string | named: `title:…` |  |

## Use your own component

Keep the name and schema, swap what is drawn. The prompt and the model's output do not change.

### React

```tsx
import { ui } from "@gistui/react/ui";

const lib = ui.extend({ Diagram: MyDiagram });
<GistUI library={lib} stream={response.body} />;
```
### Vue

```vue
<GistUI :source="answer" :components="{ Diagram: MyDiagram }" />
```
### Svelte

```svelte
<GistUI source={answer} components={{ Diagram: MyDiagram }} />
```
### Solid

```tsx
<GistUI source={answer()} components={{ Diagram: MyDiagram }} />
```
### Vanilla

```ts
import { ui } from "@gistui/vanilla/ui";

const lib = ui.extend({ Diagram: (ctx) => ({ el: myElement(ctx) }) });
```

See [Custom components](/docs/guides/custom-components/) for the full contract. Style hook: `[data-gistui="Diagram"]`.

Source: https://gistui.com/docs/components/content/diagram/index.mdx
