Best use case
Konva — 2D Canvas Graphics Framework is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
## Overview
Teams using Konva — 2D Canvas Graphics Framework should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/konva/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How Konva — 2D Canvas Graphics Framework Compares
| Feature / Agent | Konva — 2D Canvas Graphics Framework | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
## Overview
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Konva — 2D Canvas Graphics Framework
## Overview
You are an expert in Konva, the 2D canvas library for building interactive graphics applications with React. You help developers create design editors, image annotators, flowchart builders, and interactive canvases with drag-and-drop, transformations, layering, and event handling — all rendered on HTML5 Canvas for high performance.
## Instructions
### React Integration (react-konva)
```tsx
import { Stage, Layer, Rect, Circle, Text, Image, Transformer, Group } from "react-konva";
import { useState, useRef } from "react";
function DesignEditor() {
const [shapes, setShapes] = useState([
{ id: "1", type: "rect", x: 50, y: 50, width: 200, height: 100, fill: "#4f46e5" },
{ id: "2", type: "circle", x: 400, y: 150, radius: 60, fill: "#22c55e" },
{ id: "3", type: "text", x: 100, y: 200, text: "Hello World", fontSize: 24, fill: "#000" },
]);
const [selectedId, setSelectedId] = useState(null);
const transformerRef = useRef(null);
const handleDragEnd = (id, e) => {
setShapes(shapes.map(s =>
s.id === id ? { ...s, x: e.target.x(), y: e.target.y() } : s
));
};
return (
<Stage width={800} height={600} onMouseDown={(e) => {
// Deselect when clicking on empty area
if (e.target === e.target.getStage()) setSelectedId(null);
}}>
<Layer>
{shapes.map((shape) => {
const Component = shape.type === "rect" ? Rect
: shape.type === "circle" ? Circle : Text;
return (
<Component
key={shape.id}
{...shape}
draggable
onClick={() => setSelectedId(shape.id)}
onDragEnd={(e) => handleDragEnd(shape.id, e)}
/>
);
})}
{/* Transformer for resize/rotate */}
{selectedId && (
<Transformer
ref={transformerRef}
boundBoxFunc={(oldBox, newBox) => {
// Limit minimum size
if (newBox.width < 20 || newBox.height < 20) return oldBox;
return newBox;
}}
/>
)}
</Layer>
</Stage>
);
}
```
### Image Annotation
```tsx
function ImageAnnotator({ imageUrl }) {
const [annotations, setAnnotations] = useState([]);
const [isDrawing, setIsDrawing] = useState(false);
const [newRect, setNewRect] = useState(null);
const handleMouseDown = (e) => {
const pos = e.target.getStage().getPointerPosition();
setIsDrawing(true);
setNewRect({ x: pos.x, y: pos.y, width: 0, height: 0, id: Date.now().toString() });
};
const handleMouseMove = (e) => {
if (!isDrawing || !newRect) return;
const pos = e.target.getStage().getPointerPosition();
setNewRect({
...newRect,
width: pos.x - newRect.x,
height: pos.y - newRect.y,
});
};
const handleMouseUp = () => {
if (newRect && Math.abs(newRect.width) > 10) {
setAnnotations([...annotations, { ...newRect, label: "New Label" }]);
}
setIsDrawing(false);
setNewRect(null);
};
return (
<Stage width={800} height={600}
onMouseDown={handleMouseDown}
onMouseMove={handleMouseMove}
onMouseUp={handleMouseUp}>
<Layer>
<KonvaImage image={loadedImage} />
{annotations.map((ann) => (
<Group key={ann.id}>
<Rect {...ann} stroke="#ef4444" strokeWidth={2} fill="rgba(239,68,68,0.1)" />
<Text x={ann.x} y={ann.y - 20} text={ann.label} fill="#ef4444" fontSize={14} />
</Group>
))}
{newRect && <Rect {...newRect} stroke="#4f46e5" strokeWidth={2} dash={[5, 5]} />}
</Layer>
</Stage>
);
}
```
### Export
```typescript
// Export canvas as image
const stage = stageRef.current;
const dataUrl = stage.toDataURL({ pixelRatio: 2 }); // 2x for retina
// Export as blob for upload
stage.toBlob({
callback: (blob) => {
const formData = new FormData();
formData.append("image", blob, "design.png");
fetch("/api/upload", { method: "POST", body: formData });
},
pixelRatio: 2,
});
```
## Installation
```bash
npm install konva react-konva
```
## Examples
**Example 1: User asks to set up konva**
User: "Help me set up konva for my project"
The agent should:
1. Check system requirements and prerequisites
2. Install or configure konva
3. Set up initial project structure
4. Verify the setup works correctly
**Example 2: User asks to build a feature with konva**
User: "Create a dashboard using konva"
The agent should:
1. Scaffold the component or configuration
2. Connect to the appropriate data source
3. Implement the requested feature
4. Test and validate the output
## Guidelines
1. **react-konva for React** — Use `react-konva` for declarative canvas rendering; maps React's component model to Konva shapes
2. **Layers for performance** — Separate static content (background, grid) from interactive content (draggable shapes) into different `<Layer>` components
3. **Transformer for manipulation** — Use `<Transformer>` for resize/rotate handles; it provides standard design tool interactions
4. **Hit detection** — Konva handles pixel-perfect hit detection; complex shapes respond correctly to clicks and hovers
5. **Virtual canvas for large scenes** — Use stage dragging and zooming for infinite canvas experiences; only render visible shapes
6. **Export at 2x** — Use `pixelRatio: 2` when exporting for retina displays; images look crisp on all screens
7. **Undo/redo with state** — Store shape state in an array; implement undo/redo by navigating the state history
8. **Performance** — Konva handles thousands of shapes on Canvas; for 10K+ shapes, use `listening: false` on static elementsRelated Skills
microsoft-agent-framework
Create, update, refactor, explain, or review Microsoft Agent Framework solutions using shared guidance plus language-specific references for .NET and Python.
containerize-aspnet-framework
Containerize an ASP.NET .NET Framework project by creating Dockerfile and .dockerfile files customized for the project.
Canvas Skill
Display HTML content on connected Otto nodes (Mac app, iOS, Android).
startup-metrics-framework
This skill should be used when the user asks about "key startup metrics", "SaaS metrics", "CAC and LTV", "unit economics", "burn multiple", "rule of 40", "marketplace metrics", or requests guidance on tracking and optimizing business performance metrics.
framework-migration-legacy-modernize
Orchestrate a comprehensive legacy system modernization using the strangler fig pattern, enabling gradual replacement of outdated components while maintaining continuous business operations through ex
framework-migration-deps-upgrade
You are a dependency management expert specializing in safe, incremental upgrades of project dependencies. Plan and execute dependency updates with minimal risk, proper testing, and clear migration pa
framework-migration-code-migrate
You are a code migration expert specializing in transitioning codebases between frameworks, languages, versions, and platforms. Generate comprehensive migration plans, automated migration scripts, and
data-quality-frameworks
Implement data quality validation with Great Expectations, dbt tests, and data contracts. Use when building data quality pipelines, implementing validation rules, or establishing data contracts.
backtesting-frameworks
Build robust backtesting systems for trading strategies with proper handling of look-ahead bias, survivorship bias, and transaction costs. Use when developing trading algorithms, validating strategies, or building backtesting infrastructure.
agent-framework-azure-ai-py
Build Azure AI Foundry agents using the Microsoft Agent Framework Python SDK (agent-framework-azure-ai). Use when creating persistent agents with AzureAIAgentsProvider, using hosted tools (code interpreter, file search, web search), integrating MCP servers, managing conversation threads, or implementing streaming responses. Covers function tools, structured outputs, and multi-tool agents.
agent-framework
Create AI agents and workflows using Microsoft Agent Framework SDK. Supports single-agent and multi-agent workflow patterns. USE FOR: create agent, build agent, scaffold agent, new agent, agent framework, workflow pattern, multi-agent, MCP tools, create workflow. DO NOT USE FOR: deploying agents (use deploy), evaluating agents (use agent/evaluate), Azure AI Foundry agents without Agent Framework SDK.
json-canvas
Create and edit JSON Canvas files (.canvas) with nodes, edges, groups, and connections. Use when working with .canvas files, creating visual canvases, mind maps, flowcharts, or when the user mentions Canvas files in Obsidian.