BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/gaia/knowledge-graph

Knowledge Graph

gaia/knowledge-graph
FreeComponent

An interactive D3.js-powered knowledge graph visualization with zoom, pan, drag, tooltips, and export functionality.

Install it

npx shadcn@latest add https://ui.heygaia.io/r/knowledge-graph.json

Source

registry/new-york/ui/knowledge-graph.tsxui.heygaia.io/r/knowledge-graph.json · first 6 KB
1"use client";
2
3import {
4 forwardRef,
5 useCallback,
6 useEffect,
7 useImperativeHandle,
8 useRef,
9 useState,
10} from "react";
11import * as d3 from "d3";
12import { cn } from "@/lib/utils";
13
14// ============================================================================
15// Types
16// ============================================================================
17
18export interface GraphNode extends d3.SimulationNodeDatum {
19 /** Unique identifier for the node */
20 id: string;
21 /** Display label for the node */
22 label: string;
23 /** Node type/category (used for coloring) */
24 type: string;
25 /** Optional node size (default: 20) */
26 size?: number;
27 /** Optional custom color */
28 color?: string;
29 /** Optional additional data */
30 data?: unknown;
31}
32
33export interface GraphLink extends d3.SimulationLinkDatum<GraphNode> {
34 /** Source node ID or node reference */
35 source: string | GraphNode;
36 /** Target node ID or node reference */
37 target: string | GraphNode;
38 /** Optional relationship label */
39 label?: string;
40 /** Optional link strength (default: 1) */
41 strength?: number;
42}
43
44export interface KnowledgeGraphProps {
45 /** Array of nodes to display */
46 nodes: GraphNode[];
47 /** Array of links connecting nodes */
48 links: GraphLink[];
49 /** Callback when a node is clicked */
50 onNodeClick?: (node: GraphNode) => void;
51 /** Callback when a node is hovered */
52 onNodeHover?: (node: GraphNode | null) => void;
53 /** Show legend for node types */
54 showLegend?: boolean;
55 /** Show link labels */
56 showLinkLabels?: boolean;
57 /** Center node ID (will be positioned in center) */
58 centerNodeId?: string;
59 /** Additional CSS classes */
60 className?: string;
61}
62
63export interface KnowledgeGraphHandle {
64 /** Export the graph as SVG */
65 exportAsSVG: () => void;
66 /** Export the graph as PNG */
67 exportAsPNG: () => void;
68 /** Reset zoom to default */
69 resetZoom: () => void;
70}
71
72// ============================================================================
73// Utility Functions
74// ============================================================================
75
76/** Generate a deterministic color from a string */
77const stringToColor = (str: string): string => {
78 let hash = 0;
79 for (let i = 0; i < str.length; i++) {
80 const char = str.charCodeAt(i);
81 hash = (hash << 5) - hash + char;
82 hash = hash & hash;
83 }
84 const hue = Math.abs(hash) % 360;
85 const saturation = 65 + (Math.abs(hash) % 20);
86 const lightness = 50 + (Math.abs(hash) % 15);
87 return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
88};
89
90// … truncated

What it pulls in

npm packages

  • d3

Files it writes

  • registry/new-york/ui/knowledge-graph.tsx

Facts

Registry
gaia
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

ui.heygaia.io theexperiencecompany/gaia-ui on GitHub Raw registry item This item as JSON

More from gaia

All 26 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Area Chartarea-chartgaiaComponentsFree1 dep
Author Tooltipauthor-tooltipgaiaComponentsFreeno deps
Bar Chartbar-chartgaiaComponentsFree1 dep
ComposercomposergaiaComponentsFreeno deps
Email Compose Cardemail-compose-cardgaiaComponentsFreeno deps
Gauge Chartgauge-chartgaiaComponentsFree1 dep
GitHub Stars Buttongithub-stars-buttongaiaComponentsFree1 dep
Holo Cardholo-cardgaiaComponentsFree1 dep · 2 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex