---
title: "Graph Explorer"
description: "Graph Explorer component - a knowledge graph of 2,000 to 4,000,000 nodes: a worker draws the far field into a canvas, a bounded pool of DOM nodes shows what you read, semantic zoom dives into clusters, and outlets put breadcrumb, search, outline, details and relations wherever the page wants them."
slug: "graph-explorer"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, StatesSection, DocText, DocLink, SkillField, SkillText, SkillRow, SkillGrid, Variant, ApiPill, ApiSection, H2 } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="graph-explorer" title="Graph Explorer" component="graph-explorer">
  A graph as one element: a <code>&lt;div class="graph-explorer"&gt;</code> becomes a focusable viewport over a graph of up to four million nodes. A Web Worker builds the graph and draws the far field into a canvas; only the nodes worth reading get DOM - chips, cards, labels along the edges - from renderers you can replace. What it shows is attributes: the cluster you are in (<code>data-focus</code>), the selection (<code>data-selected</code>), the layers shown (<code>data-layers</code>), the expanded page (<code>data-expanded</code>). Everything around it - breadcrumb, search, outline, details, relations - is an outlet the page places.
</PageHeader>

<SkillPanel component="graph-explorer">
  <SkillField label="Native basis">
<SkillText>A <code>&lt;div role="application"&gt;</code> with a canvas for the worker's bitmap, an SVG for the highlighted edges and pooled <code>&lt;div&gt;</code> slots for nodes and labels. The state is on the element as <code>data-*</code> attributes; the drawing and the outlets' content are the runtime's.</SkillText>
  </SkillField>

  <SkillField label="Built from">
<SkillText><DocLink href="badge.html">Badge</DocLink>, <DocLink href="button.html">Button</DocLink>, <DocLink href="breadcrumb.html">Breadcrumb</DocLink>, <DocLink href="card.html">Card</DocLink>, <DocLink href="input.html">Input</DocLink>, <DocLink href="kbd.html">Kbd</DocLink>, <DocLink href="table.html">Table</DocLink>; Expand works with a <DocLink href="panel.html">Panel</DocLink>.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API" title="the graph off the main thread"><code>Worker</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas" title="the far field, drawn in the worker"><code>OffscreenCanvas</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmapRenderingContext" title="the bitmap, shown without a copy"><code>bitmaprenderer</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events" title="pan, pinch, press and hold"><code>Pointer Events</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/Popover_API" title="the keyboard map"><code>popover</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/mask" title="the icons"><code>mask</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver" title="the viewport refits"><code>ResizeObserver</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.graph-explorer</code>
    <code>.graph-explorer-node</code>
    <code>.graph-explorer-chip</code>
    <code>.graph-explorer-card</code>
    <code>.graph-explorer-edge-label</code>
    <code>.graph-explorer-icon</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Upstream">
<SkillGrid>
    <Variant name="graph-explorer PoC" description="The design study's proof of concept this component is ported from (MIT, Aron Homberg)" />
    <Variant name="Lucide (lucide-static 0.469.0)" description="The icon subset, drawn as CSS masks (ISC)" />
  </SkillGrid>
  </SkillField>

  <SkillField label="Accessibility">
<SkillText dense>• One tab stop: arrows move the focus to the nearest node in that direction, Enter enters a cluster, Space selects, Backspace moves up, ? opens the keyboard map</SkillText>
  <SkillText dense>• The view, the focused node and the neighbour ring (Jump to a neighbour) are announced in a live region (a bound status output, else the explorer's own)</SkillText>
  <SkillText dense>• Reduced motion: jumps instead of flights, no animated edges; forced colors: system colors on the canvas and in the DOM</SkillText>
  </SkillField>
</SkillPanel>

```html example label="Graph Explorer" hint="A synthetic service graph of 100,000 nodes: six domains, their systems, their entities. Wheel or pinch to zoom, drag to pan; click a node to select it, double click or Enter to go in. The State tab writes the same attributes the clicks do."
<div
  class="graph-explorer"
  id="graph"
  data-nodes="100000"
  data-frame
  aria-label="A service graph"
  style="block-size: 28rem"
  data-state-demo
></div>
```

<H2 id="outlets">Outlets</H2>

<DocText>An outlet is any element the page binds with <code>data-graph-explorer-for="&lt;id&gt;"</code>: <code>data-graph-explorer-outlet</code> names what the runtime puts in it - <code>breadcrumb</code>, <code>search</code>, <code>outline</code>, <code>details</code>, <code>relations</code>, <code>layers</code>, <code>updates</code> - and <code>data-graph-explorer-output</code> a readout - <code>details-title</code>, <code>relations-title</code>, <code>view</code>, <code>status</code>. <code>data-graph-explorer-action</code> buttons move up, fit, switch Live mode or open the keyboard map. The <DocLink href="scaffold-knowledge-graph.html">Knowledge Graph</DocLink> scaffold places them in Panels.</DocText>

```html example label="Breadcrumb, search, outline and details" schema="none" hint="Pick a node in the outline or the graph: the details show it. The breadcrumb's crumbs move up; the search flies anywhere." previewStyle="align-items:stretch;"
<div class="grid gap-2">
  <div class="flex flex-wrap items-center gap-2">
    <div class="flex-1 min-w-0" data-graph-explorer-for="outlets" data-graph-explorer-outlet="breadcrumb"></div>
    <div class="w-full max-w-64" data-graph-explorer-for="outlets" data-graph-explorer-outlet="search"></div>
    <button
      class="btn"
      data-variant="outline"
      data-size="sm"
      type="button"
      data-graph-explorer-for="outlets"
      data-graph-explorer-action="up"
    >
      Up
    </button>
  </div>
  <div class="grid gap-2" style="grid-template-columns: 12rem minmax(0, 1fr) 16rem; block-size: 26rem">
    <div class="card overflow-hidden" data-graph-explorer-for="outlets" data-graph-explorer-outlet="outline"></div>
    <div
      class="graph-explorer"
      id="outlets"
      data-nodes="100000"
      data-seed="11"
      data-frame
      aria-label="A service graph"
    ></div>
    <div class="card p-3 overflow-auto" data-graph-explorer-for="outlets" data-graph-explorer-outlet="details"></div>
  </div>
  <p class="text-sm text-muted-foreground m-0">
    <output data-graph-explorer-for="outlets" data-graph-explorer-output="status"></output>
  </p>
</div>
```

<H2 id="your-own-graph">Your own graph</H2>

<DocText>With <code>data-source="external"</code> the explorer generates nothing and waits; <code>df$.shadcn.graphExplorer.load(el, data)</code> hands it the page's graph as typed arrays. Cluster 0 is the root, the clusters come in BFS order with each one's children side by side (<code>clusters.parent</code> never decreases), the nodes are sorted by cluster and the links are an out-CSR over the nodes: node <code>i</code>'s targets are <code>edges.target[edges.start[i]]</code> up to <code>edges.start[i + 1]</code>. A cluster holds clusters or nodes, never both, and at most 1,024 of them; the depth varies up to 256 cluster levels - a file beside the folders of its package is a leaf one level higher. Labels name what the explorer draws and finds; <code>ref</code> carries the page's own id into <code>GraphNode.ref</code>, the search hits and the subtree rows, so a detail renderer can show the page's record.</DocText>

<DocText>The worker checks the whole graph before it changes anything: lengths, index ranges, the BFS order, the CSR, every type index, the bounds. Data it refuses fires <code>graph-explorer-error</code> with the first thing wrong and leaves the graph shown as it was. An array backed by a <code>SharedArrayBuffer</code> is refused, since the page could change it after the check. A graph it accepts replaces the one shown - a generated one too - at its top, nothing selected, without the old graph's updates, search query or outline filter. <code>load()</code> resolves <code>true</code> once its graph shows and <code>false</code> when it was refused or a later <code>load()</code> superseded it. Each view still finds its own cycles, so a loop of three functions in one file is marked in that file's view. Health, the circuit breakers, Live mode and the generated owner, rows and freshness belong to a generated graph; a loaded graph keeps Nodes, Relations and Labels, and its changes come through <code>update()</code>.</DocText>

<DocText>Why arrays and not a URL: HYPOTHESIS: a page that shows its own graph has it in memory already, usually in a worker of its own, so a <code>data-src</code> URL would serialize it once more and parse it again. <code>load()</code> transfers the typed arrays instead - VERIFIED: they are empty on the page afterwards, also when the data is refused, so a retry builds them anew (<code>tests/e2e/site/graph-explorer-data.e2e.ts</code>); a transferred buffer changes owner instead of being copied, and only the label and ref lists are copied. VERIFIED, from a one-off headless Chromium probe on an Apple M5 Max (not from the test): at 1M nodes, 3M links and 256 children per cluster, <code>load()</code> shows the graph after 426 ms, 168 ms of it the check and the install, copying 1M labels and 1M refs included; then a node's details take 15-22 ms, the rows of a 65,536-entity cluster 62 ms, a view 24 ms and a full search 119 ms.</DocText>

<DocText>Why packed labels: <code>nodes.label</code> and <code>nodes.ref</code> may also come as UTF-8 end to end, a <code>GraphExplorerStrings</code> of <code>offsets</code> (one entry more than the nodes; string <code>i</code> is <code>bytes[offsets[i]]</code> up to <code>offsets[i + 1]</code>) and <code>bytes</code>. Those two buffers move to the worker like the typed arrays, so a page with millions of nodes keeps no string per node and <code>load()</code> copies none; the worker decodes a label when it shows it or names it in a hit, and the search reads the bytes, with the same hits as over a list (<code>tests/e2e/site/graph-explorer-data.e2e.ts</code> checks ASCII, umlauts and the Kelvin sign, which lowercases to an ASCII k). The clusters keep their lists: there are few of them. The example below packs its labels and refs with <code>TextEncoder</code>. VERIFIED, from a one-off headless Chromium probe on the same machine (1M nodes, 1M links, 1,000 per cluster, three runs each): <code>load()</code> took 197-224 ms with lists and 114-120 ms packed; a full search that finds nothing took 23-26 ms over the lists and 43-47 ms over the bytes. Either way the search scans 120,000 entities at a time and answers the other requests in between.</DocText>

<DocText>Why bounds and not any fan-out or depth: VERIFIED, from one-off probes of the same kind: a view lays out its children in time that grows with the square of their number - 1,000 children show after 120 ms, 8,000 after 8.8 s - and the worker answers nothing meanwhile; a chain of 20,000 cluster levels overflowed the worker's stack in <code>subtree()</code>. A page with a bigger cluster splits it into groups, which also keeps a view readable. VERIFIED: 256 levels load, navigate and walk (the test above).</DocText>

```html example label="A code base as a graph" schema="none" hint="A repository built in the page's script: packages, folders, files and the functions in them, about 2,500 nodes on four cluster levels. Search for collectCycle: it closes a loop of three functions in graph.ts, marked in that file's view. Another graph loads a second code base in place of the first." previewStyle="align-items:stretch;"
<div class="grid gap-2">
  <div class="flex flex-wrap items-center gap-2">
    <div class="flex-1 min-w-0" data-graph-explorer-for="own" data-graph-explorer-outlet="breadcrumb"></div>
    <div class="w-full max-w-64" data-graph-explorer-for="own" data-graph-explorer-outlet="search"></div>
    <div data-graph-explorer-for="own" data-graph-explorer-outlet="layers"></div>
    <button class="btn" data-variant="outline" data-size="sm" type="button" id="own-next">Another graph</button>
  </div>
  <div class="grid gap-2" style="grid-template-columns: minmax(0, 1fr) 18rem; block-size: 28rem">
    <div class="graph-explorer" id="own" data-source="external" data-frame aria-label="A code base"></div>
    <div class="card p-3 overflow-auto" data-graph-explorer-for="own" data-graph-explorer-outlet="details"></div>
  </div>
  <p class="text-sm text-muted-foreground m-0"><output id="own-info">Building the graph...</output></p>
</div>
<script>
  addEventListener('DOMContentLoaded', () => {
    const ge = df$.shadcn.graphExplorer;
    const PACKAGES = ['core', 'ui', 'data', 'cli', 'net', 'docs'];
    const FOLDERS = ['src', 'lib', 'util', 'io'];
    const FILES = ['graph', 'parse', 'render', 'store', 'query', 'cache', 'types', 'stream', 'events', 'paths'];
    const VERBS = ['parse', 'render', 'load', 'save', 'build', 'merge', 'split', 'check', 'format', 'resolve'];
    const NOUNS = ['Config', 'Row', 'Token', 'Tree', 'Path', 'Query', 'Cache', 'Event', 'Schema', 'Page'];
    // a repeatable random number generator (mulberry32): the same seed builds the same code base
    const random = (seed) => () => {
      seed = (seed + 0x6d2b79f5) | 0;
      let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);
      t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
      return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
    };

    // strings packed as UTF-8 end to end: two buffers that move to the worker instead of a string per node
    function utf8(list) {
      const parts = list.map((s) => new TextEncoder().encode(s)),
        offsets = new Int32Array(list.length + 1);
      parts.forEach((p, i) => (offsets[i + 1] = offsets[i] + p.length));
      const bytes = new Uint8Array(offsets[list.length]);
      parts.forEach((p, i) => bytes.set(p, offsets[i]));
      return { offsets, bytes };
    }

    // repository > packages > folders > files > functions; each package also holds an index.ts beside its folders,
    // a file one level higher than the others
    function codebase(seed, packages) {
      const rnd = random(seed);
      const pick = (list) => list[Math.floor(rnd() * list.length)];
      const shuffled = (list) => {
        const a = [...list];
        for (let i = a.length - 1; i > 0; i--) {
          const j = Math.floor(rnd() * (i + 1));
          [a[i], a[j]] = [a[j], a[i]];
        }
        return a;
      };
      // BFS order: the packages, then each package's children (index.ts and its folders), then each folder's files
      const clusters = [{ parent: -1, type: 0, label: 'repository' }];
      const add = (parent, type, label) => clusters.push({ parent, type, label }) - 1;
      const files = [],
        folders = [];
      const pkgs = packages.map((name) => add(0, 1, name));
      pkgs.forEach((p, k) => {
        files.push({ cluster: add(p, 3, 'index.ts'), path: packages[k] + '/index.ts', pkg: p });
        for (const name of FOLDERS.slice(0, 3))
          folders.push({ cluster: add(p, 2, name), path: packages[k] + '/' + name, pkg: p });
      });
      for (const f of folders) {
        const names =
          f.path === 'core/src' ? ['graph', ...shuffled(FILES.slice(1)).slice(0, 4)] : shuffled(FILES).slice(0, 5);
        for (const name of names)
          files.push({ cluster: add(f.cluster, 3, name + '.ts'), path: `${f.path}/${name}.ts`, pkg: f.pkg });
      }
      // the nodes sorted by cluster: the files are in cluster order already
      const nodes = [],
        byPkg = new Map(pkgs.map((p) => [p, []]));
      for (const f of files) {
        const taken = new Set();
        const count = 28 + Math.floor(rnd() * 7);
        for (let i = 0; i < count; i++) {
          let name =
            f.path === 'core/src/graph.ts' && i < 3
              ? ['visitNode', 'expandEdge', 'collectCycle'][i]
              : pick(VERBS) + pick(NOUNS);
          while (taken.has(name)) name += '2';
          taken.add(name);
          byPkg.get(f.pkg).push(nodes.length);
          nodes.push({
            cluster: f.cluster,
            pkg: f.pkg,
            type: Math.floor(rnd() * 3),
            label: name,
            ref: f.path + '#' + name,
          });
        }
      }
      // links go to later nodes only (no cycle): most within the file, some within the package, a few anywhere; then
      // one link back closes visitNode -> expandEdge -> collectCycle -> visitNode
      const out = nodes.map(() => []);
      nodes.forEach((n, i) => {
        const links = 1 + Math.floor(rnd() * 3);
        for (let k = 0; k < links; k++) {
          const u = rnd();
          let t = -1;
          if (u < 0.6) t = i + 1 + Math.floor(rnd() * 4);
          else if (u < 0.85)
            t = pick(
              byPkg
                .get(n.pkg)
                .filter((j) => j > i)
                .concat(-1),
            );
          else if (i + 1 < nodes.length) t = i + 1 + Math.floor(rnd() * (nodes.length - i - 1));
          if (u < 0.6 && nodes[t]?.cluster !== n.cluster) t = -1;
          if (t > i) out[i].push([t, u < 0.6 ? 0 : u < 0.85 ? 1 : 2]);
        }
      });
      const first = nodes.findIndex((n) => n.label === 'visitNode');
      if (first >= 0) {
        out[first].push([first + 1, 0]);
        out[first + 1].push([first + 2, 0]);
        out[first + 2].push([first, 0]);
      }
      const start = new Int32Array(nodes.length + 1);
      out.forEach((list, i) => (start[i + 1] = start[i] + list.length));
      const flat = out.flat();
      return {
        clusters: {
          parent: Int32Array.from(clusters, (c) => c.parent),
          type: Uint8Array.from(clusters, (c) => c.type),
          label: clusters.map((c) => c.label),
        },
        nodes: {
          cluster: Int32Array.from(nodes, (n) => n.cluster),
          type: Uint8Array.from(nodes, (n) => n.type),
          label: utf8(nodes.map((n) => n.label)),
          ref: utf8(nodes.map((n) => n.ref)),
        },
        edges: {
          start,
          target: Int32Array.from(flat, (l) => l[0]),
          type: Uint8Array.from(flat, (l) => l[1]),
        },
        types: {
          cluster: ['Repository', 'Package', 'Folder', 'File'],
          node: ['function', 'class', 'constant'],
          edge: ['calls', 'imports', 'reads'],
        },
      };
    }

    const info = document.getElementById('own-info');
    let seed = 1;
    async function show() {
      const data = codebase(seed, PACKAGES.slice(0, seed % 2 ? 5 : 6));
      const nodes = data.nodes.cluster.length,
        links = data.edges.target.length;
      info.textContent = 'Loading...';
      // the typed arrays and the packed labels and refs move to the explorer's worker: they are empty here once load() returns
      if (await ge.load('#own', data))
        info.textContent = `${nodes.toLocaleString('en-US')} nodes · ${links.toLocaleString('en-US')} links · seed ${seed}`;
    }
    document.getElementById('own-next').addEventListener('click', () => {
      seed++;
      void show();
    });
    void show();
  });
</script>
```

<H2 id="live-mode">Live mode and updates</H2>

<DocText>An update is one change in the graph - a node or a link, the layer it belongs to, a line of text. For eight seconds a changed node carries a glowing dot at its top right and a changed link lights up in its layer's colour and fades. The <code>updates</code> outlet lists every update of the shown layers, newest first, one compact row each in a <DocLink href="virtual-list.html">Virtual List</DocLink>; a row selects its node or its link (the link's view is entered first). The <code>live</code> action starts Live mode, the explorer's simulation: breakers trip and close (Health), nodes deploy (Nodes), traffic moves (Relations), counts change (Labels). An app adds its own with <code>df$.shadcn.graphExplorer.update(el, change)</code>, and an <code>update</code> plugin renders the rows its way.</DocText>

```html example label="Updates in Live mode" schema="none" hint="Press Live mode: changed nodes get a glowing dot, changed links light up in their layer's colour, and every change lands in Updates, newest first. Hide Health in the layer switch and its changes leave the list; click a row to select its node or link. Add a change adds one of the page's own, with its own row renderer." previewStyle="align-items:stretch;"
<div class="grid gap-2">
  <div class="flex flex-wrap items-center gap-2">
    <button
      class="btn"
      data-variant="outline"
      data-size="sm"
      type="button"
      aria-pressed="false"
      data-graph-explorer-for="live"
      data-graph-explorer-action="live"
    >
      Live mode
    </button>
    <button class="btn" data-variant="ghost" data-size="sm" type="button" id="live-add">Add a change</button>
    <div class="ml-auto" data-graph-explorer-for="live" data-graph-explorer-outlet="layers"></div>
  </div>
  <div class="grid gap-2" style="grid-template-columns: minmax(0, 1fr) 20rem; block-size: 26rem">
    <div
      class="graph-explorer"
      id="live"
      data-nodes="100000"
      data-seed="13"
      data-frame
      data-layers="nodes relations health"
      aria-label="A service graph in Live mode"
    ></div>
    <div class="card overflow-hidden" data-graph-explorer-for="live" data-graph-explorer-outlet="updates"></div>
  </div>
</div>
<script>
  addEventListener('DOMContentLoaded', () => {
    const ge = df$.shadcn.graphExplorer;
    // the page's own rows: a release names its version as a Badge
    ge.register('global', {
      kind: 'update',
      name: 'releases',
      update: {
        match: (u) => (u.type === 'release' ? 1 : false),
        render: (u, c) =>
          c.html`<span class="indicator-dot" data-size="sm" aria-hidden="true"></span><span class="graph-explorer-update-label">${u.label}</span><span class="badge" data-variant="secondary">${u.text}</span><time class="graph-explorer-update-time">${c.time(u.time)}</time>`,
      },
    });
    let release = 0;
    df$('#live-add').on('click', () => {
      const domain = 'c' + (1 + (release % 6));
      ge.update('#live', { target: domain, type: 'release', text: 'v2.' + release++, layer: 'nodes' });
    });
  });
</script>
```

<H2 id="icons">Icons</H2>

<DocText>Renderers draw icons with <code>ctx.icon(name, \{ size, tone, label \})</code>: a Lucide subset as CSS masks - one empty element each, cheap to morph, painted in the current color. Sizes <code>xs</code>, <code>sm</code>, <code>lg</code> and <code>xl</code> go around the 1rem default; a <code>tone</code> takes the graph's colour role; with a <code>label</code> the icon is an image, else decorative. <code>df$.shadcn.graphExplorer.registerIcon(name, shapes)</code> adds one.</DocText>

```html example label="Icon sizes and tones" schema="none"
<p class="flex items-center gap-3">
  <i class="graph-explorer-icon" data-icon="database" data-size="xs" aria-hidden="true"></i>
  <i class="graph-explorer-icon" data-icon="database" data-size="sm" aria-hidden="true"></i>
  <i class="graph-explorer-icon" data-icon="database" aria-hidden="true"></i>
  <i class="graph-explorer-icon" data-icon="database" data-size="lg" aria-hidden="true"></i>
  <i class="graph-explorer-icon" data-icon="database" data-size="xl" aria-hidden="true"></i>
  <i
    class="graph-explorer-icon"
    data-icon="zap-off"
    data-size="xl"
    data-tone="danger"
    role="img"
    aria-label="Breaker open"
  ></i>
  <i
    class="graph-explorer-icon"
    data-icon="shield-check"
    data-size="xl"
    data-tone="ok"
    role="img"
    aria-label="Breaker closed"
  ></i>
</p>
```

<StatesSection>
  <p class="text-sm text-muted-foreground m-0 mb-3">Named states via the shared State API, driven per instance through the bound <code>api</code>. The state is the element's attributes - a click, a zoom into a cluster, the layer switch or an attribute written from outside changes it without <code>setState</code>, and <code>getState()</code> reports it:</p>
  <ul class="text-sm text-muted-foreground m-0 mb-3 ps-5">
    <li><code>default</code> - the top level, nothing selected (<code>data-focus</code> and <code>data-selected</code> removed)</li>
    <li><code>selected</code> - <code>config.selected</code> nodes picked at the top level; an id deeper down flies there, and the state lands in <code>focused</code></li>
    <li><code>focused</code> - inside the cluster <code>config.focus</code> (the view dives there), with or without a selection</li>
  </ul>
  <p class="text-sm text-muted-foreground m-0 mb-3">Every state takes <code>layers</code> (<code>data-layers</code>), <code>compact</code> (<code>data-compact</code>) and <code>expanded</code> (<code>data-expanded</code>: the first selected node's page, the details Panel maximized). A config that names a focus or a selection asks for the state that shows it. Events: <code>graph-explorer-select</code>, <code>graph-explorer-focus</code>, <code>graph-explorer-view</code> (the camera came to rest), <code>graph-explorer-layers</code>, <code>graph-explorer-action</code>, <code>graph-explorer-error</code>.</p>
  <p class="text-sm text-muted-foreground">The first example carries <code>data-state-demo</code>; <code>bun run screenshots</code> drives it via <code>el.api.setState(name)</code> and captures <code>screenshots/\{mode\}/graph-explorer-\{state\}.png</code>.</p>

Machine contract - verified against <a class="link" href="../schemas/graph-explorer.schema.json"><code>graph-explorer.schema.json</code></a> by <code>bun run verify</code>:

```states
| State | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
| `layers` | `string` | `—` | `"nodes relations"` | The layers shown, space separated: nodes, relations, labels, health or a plugin's (`data-layers`, absent for the base layers; empty: only the circles). |
| `compact` | `boolean` | `true`, `false` | `false` | Every node as its one-line chip, never a card (`data-compact`). |
| `focused` | `string` | `—` | `""` | The cluster the view is in (`setState('focused', { focus })`, observed from `data-focus`). |
| `selected` | `string` | `—` | `""` | The selected node ids, space separated (observed from `data-selected`). |
| `edge` | `string` | `—` | `""` | The selected link, `<source id>><target id>` (observed from `data-selected-edge`); nodes and a link are never selected together. |
| `expanded` | `boolean` | `true`, `false` | `false` | The selection's full page in the details outlet - the first selected node's or the link's (`data-expanded`). |
```

</StatesSection>

<ApiSection component="graph-explorer" />

<SourceFiles component="graph-explorer" section="css" />

<SourceFiles component="graph-explorer" section="js" jsTitle="JS" />

</DocPage>
