infinite-canvas
Skill0 starsChanged 4 months agoMITView on GitHub
Build nested, navigable canvas UIs with React Flow. Users can zoom into nodes to reveal child canvases - infinite depth.
In this repository37 other files it gives its agents.
- .agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- vercel-composition-patterns/AGENTS.mdAGENTS.md
- senior-frontendSkill
- vercel-composition-patternsSkill
- bento-designSkill
- fanned-cardsSkill
- flip-cardSkill
- floating-quotesSkill
- githubSkill
- glassmorphism-uiSkill
- gmail-proxySkill
- googleSkill
- hippocampusSkill
- html-pdf-exportSkill
- iframe-previewSkill
- matrix-textSkill
- nextjs-apiSkill
- nextjs-expertSkill
- pinterestSkill
- railway-deploySkill
- remotion-videoSkill
- scramble-textSkill
- scroll-video-heroSkill
- senior-frontendSkill
- SEOSkill
- ship-websiteSkill
- sound-engineSkill
- stripe-best-practicesSkill
- tilt-cardSkill
- tube-summarySkill
- upload-postSkill
- vercel-composition-patternsSkill
- vercel-deploySkill
- vercel-react-best-practicesSkill
- vertical-fanned-cardsSkill
- video-contentSkill
- war-roomSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 253
Debounce position saves: - don't spam API on every drag
- Distinctive: line 255
Lazy load: - only fetch nodes for current level
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Infinite Canvas Skill
Build nested, navigable canvas UIs with React Flow. Users can zoom into nodes to reveal child canvases - infinite depth.
When to Use
- Mind maps, knowledge graphs, visual databases
- Nested folder/category systems
- Any UI where items can contain other items
- Visual organization tools
Architecture
React Flow (canvas) + Zustand (state) + Redis/DB (persistence)Core Concepts
1. Data Model
interface CanvasNode {
id: string;
parentId: string | null; // null = root level
type: 'category' | 'container' | 'item';
title: string;
position: { x: number; y: number };
childCount: number; // cached for badges
// Type-specific fields
color?: string;
icon?: string;
content?: string;
url?: string;
}
interface NavigationState {
path: PathItem[]; // breadcrumb trail
currentParentId: string | null;
viewport: Viewport; // saved per level
}2. State Management (Zustand)
import { create } from 'zustand';
interface CanvasStore {
nodes: CanvasNode[];
path: PathItem[];
currentParentId: string | null;
viewport: Viewport;
loading: boolean;
// Navigation
navigateInto: (nodeId: string) => void;
navigateBack: () => void;
loadLevel: (parentId: string | null) => Promise<void>;
// CRUD
createNode: (data: Partial<CanvasNode>) => Promise<void>;
updateNode: (id: string, data: Partial<CanvasNode>) => Promise<void>;
deleteNode: (id: string) => Promise<void>;
updatePositions: (updates: PositionUpdate[]) => Promise<void>;
}
export const useCanvasStore = create<CanvasStore>((set, get) => ({
nodes: [],
path: [{ id: 'root', title: 'Home' }],
currentParentId: null,
viewport: { x: 0, y: 0, zoom: 0.75 },
loading: false,
navigateInto: async (nodeId) => {
const node = get().nodes.find(n => n.id === nodeId);
if (!node) return;
set(state => ({
path: [...state.path, { id: node.id, title: node.title }],
currentParentId: node.id,
}));
await get().loadLevel(nodeId);
},
navigateBack: async () => {
const { path } = get();
if (path.length <= 1) return;
const newPath = path.slice(0, -1);
const newParentId = newPath.length > 1 ? newPath[newPath.length - 1].id : null;
set({ path: newPath, currentParentId: newParentId });
await get().loadLevel(newParentId);
},
loadLevel: async (parentId) => {
set({ loading: true });
const res = await fetch(`/api/nodes?parentId=${parentId || 'root'}`);
const { nodes, viewport } = await res.json();
set({ nodes, viewport, loading: false });
},
}));3. Canvas Component
import { ReactFlow, Background, Controls, MiniMap } from '@xyflow/react';
import { useCanvasStore } from '../lib/store';
export default function Canvas() {
const { nodes, currentParentId, updatePositions } = useCanvasStore();
const flowNodes = nodes.map(node => ({
id: node.id,
type: node.type,
position: node.position,
data: { node },
}));
const handleNodeDragStop = (event, node) => {
// Debounce save positions to API
updatePositions([{ id: node.id, position: node.position }]);
};
return (
<ReactFlow
nodes={flowNodes}
edges={[]}
nodeTypes={nodeTypes}
onNodeDragStop={handleNodeDragStop}
minZoom={0.1}
maxZoom={2}
>
<Background />
<Controls />
<MiniMap />
</ReactFlow>
);
}4. Custom Node Components
function CategoryNode({ data, selected }) {
const { navigateInto } = useCanvasStore();
const node = data.node;
const handleDoubleClick = () => {
if (node.childCount > 0) {
navigateInto(node.id);
}
};
return (
<div
onDoubleClick={handleDoubleClick}
className={`p-4 rounded-xl border-2 cursor-pointer ${
selected ? 'ring-2 ring-white/30' : ''
}`}
style={{ borderColor: node.color }}
>
<span className="text-2xl">{node.icon}</span>
<h3 className="font-bold">{node.title}</h3>
{node.childCount > 0 && (
<span className="text-xs opacity-60">{node.childCount} items</span>
)}
</div>
);
}5. Breadcrumb Navigation
function Breadcrumb() {
const { path, loadLevel } = useCanvasStore();
return (
<nav className="flex items-center gap-2">
{path.map((item, index) => (
<Fragment key={item.id}>
{index > 0 && <ChevronRight className="w-4 h-4" />}
<button
onClick={() => {
const newPath = path.slice(0, index + 1);
const parentId = index === 0 ? null : item.id;
loadLevel(parentId);
}}
className={index === path.length - 1 ? 'font-bold' : 'opacity-60'}
>
{item.title}
</button>
</Fragment>
))}
</nav>
);
}6. API Routes (Next.js)
// /api/nodes/route.ts
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const parentId = searchParams.get('parentId');
const nodes = await redis.getChildren(parentId === 'root' ? null : parentId);
const viewport = await redis.getViewport(parentId);
return Response.json({ nodes, viewport });
}
export async function POST(request: Request) {
const body = await request.json();
const node = await redis.createNode(body);
return Response.json({ node });
}Keyboard Shortcuts
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape' && path.length > 1) {
navigateBack();
}
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [path.length, navigateBack]);Dependencies
{
"@xyflow/react": "^12.0.0",
"zustand": "^4.5.0",
"framer-motion": "^11.0.0"
}Best Practices
- Save viewport per level - restore when navigating back
- Cache childCount - show badges without loading children
- Debounce position saves - don't spam API on every drag
- Use Framer Motion - smooth transitions between levels
- Lazy load - only fetch nodes for current level
Files
examples/store.ts- Full Zustand storeexamples/Canvas.tsx- Canvas componentexamples/nodes/- Custom node componentstemplates/- Starter template
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

