Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

konva

БесплатноБез исполняемых скриптовНе проверен

Builds interactive 2D canvas applications with Konva, a JavaScript library that draws shapes, text and images on HTML5 Canvas with layers, events and…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Konva — 2D Canvas Graphics Framework

Overview

Konva is a 2D canvas library for interactive graphics: a scene graph of stage, layers, groups and shapes with hit detection, drag-and-drop, transforms, animation and export, all rendered on HTML5 Canvas. It works as plain JavaScript and, through react-konva, as declarative React components — the usual base for design editors, image annotators, flowchart builders and whiteboards.

Konva 10 (September 2025) is ESM-only and no longer loads a Node.js canvas by itself; the current release is 10.7.0. react-konva versions follow React: the major version must match, and react-konva 19.3 needs React 19.3 or newer — the unpinned install fails with ERESOLVE on React 19.2 and 18.

Instructions

Installation

npm install konva react-konva            # React 19.3 (react-konva 19.3)
npm install konva [email protected]       # React 19.2
npm install konva react-konva@18         # React 18
npm install use-image                    # hook that loads an image for <Image>

Without a bundler, load https://unpkg.com/konva@10/konva.min.js with a <script> tag; it defines the global Konva. In CommonJS, Konva 10 is require("konva").default.

Plain JavaScript

import Konva from "konva";

const stage = new Konva.Stage({ container: "seat-map", width: 640, height: 360 });  // id of a <div>
const layer = new Konva.Layer();
stage.add(layer);

for (let col = 0; col < 8; col++) {
  const seat = new Konva.Circle({
    x: 80 + col * 68, y: 70, radius: 22,
    fill: "#e5e7eb", stroke: "#6b7280", name: "seat", id: `A${col + 1}`,
  });
  // Changing an attribute redraws the layer; no manual draw() call is needed
  seat.on("click tap", () => seat.fill(seat.fill() === "#22c55e" ? "#e5e7eb" : "#22c55e"));
  layer.add(seat);
}

const selected = () => stage.find(".seat").filter((s) => s.fill() === "#22c55e").map((s) => s.id());

Selectors work like CSS: "#A3" by id, ".seat" by name, "Circle" by class.

React Integration (react-konva)

import { Stage, Layer, Rect, Circle, Text, Transformer } from "react-konva";
import { useEffect, useRef, useState } from "react";
import type Konva from "konva";

type Shape = { id: string; type: "rect" | "circle" | "text"; x: number; y: number; rotation?: number;
  width?: number; height?: number; radius?: number; text?: string; fontSize?: number; fill: string };

function DesignEditor() {
  const [shapes, setShapes] = useState<Shape[]>([
    { id: "card", type: "rect", x: 50, y: 50, width: 200, height: 100, fill: "#4f46e5" },
    { id: "badge", type: "circle", x: 400, y: 150, radius: 60, fill: "#22c55e" },
    { id: "title", type: "text", x: 100, y: 200, text: "Spring Sale", fontSize: 24, fill: "#111827" },
  ]);
  const [selectedId, setSelectedId] = useState<string | null>(null);
  const layerRef = useRef<Konva.Layer>(null);
  const transformerRef = useRef<Konva.Transformer>(null);

  // A Transformer shows nothing until it is given the nodes to control
  useEffect(() => {
    const node = selectedId ? layerRef.current?.findOne("#" + selectedId) : null;
    transformerRef.current?.nodes(node ? [node] : []);
  }, [selectedId]);

  const update = (id: string, attrs: Partial<Shape>) =>
    setShapes((prev) => prev.map((s) => (s.id === id ? { ...s, ...attrs } : s)));

  return (
    <Stage width={800} height={600} onMouseDown={(e) => {
      // Deselect when clicking on empty area
      if (e.target === e.target.getStage()) setSelectedId(null);
    }}>
      <Layer ref={layerRef}>
        {shapes.map(({ type, ...attrs }) => {
          const Component: React.ElementType = type === "rect" ? Rect : type === "circle" ? Circle : Text;
          return (
            <Component
              key={attrs.id}
              {...attrs}
              draggable
              onClick={() => setSelectedId(attrs.id)}
              onDragEnd={(e: Konva.KonvaEventObject<DragEvent>) =>
                update(attrs.id, { x: e.target.x(), y: e.target.y() })}
              onTransformEnd={(e: Konva.KonvaEventObject<Event>) => {
                // Transformer changes scale, not size: fold the scale back into the size
                const node = e.target;
                const scaleX = node.scaleX(), scaleY = node.scaleY();
                node.scale({ x: 1, y: 1 });
                update(attrs.id, {
                  x: node.x(), y: node.y(), rotation: node.rotation(),
                  ...(type === "rect" && { width: node.width() * scaleX, height: node.height() * scaleY }),
                  ...(type === "circle" && { radius: (attrs.radius ?? 0) * scaleX }),
                  ...(type === "text" && { fontSize: (attrs.fontSize ?? 12) * scaleY }),
                });
              }}
            />
          );
        })}

        {/* Transformer for resize/rotate */}
        <Transformer
          ref={transformerRef}
          boundBoxFunc={(oldBox, newBox) =>
            // Limit minimum size
            newBox.width < 20 ||
Полный SKILL.md на GitHub

Установить konva в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл konva?

Builds interactive 2D canvas applications with Konva, a JavaScript library that draws shapes, text and images on HTML5 Canvas with layers, events and drag-and-drop. Use when a user asks to create drawing tools, image editors, interactive graphics, drag-and-drop interfaces, or canvas-based UIs using Konva or react-konva.

Как установить скилл konva?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл konva запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить konva с