npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sewdn/diagram-kit

v0.1.0

Published

SVG architecture diagrams in React: boxes, layers, layouts, edges, pan and zoom.

Readme

@sewdn/diagram-kit

React-first SVG diagram toolkit for documentation portals. It ships layout primitives, box templates, connection routing, a pan/zoom SVG viewer, and a lil-gui based controls panel with persisted settings + export helpers.

Features

  • React SVG diagrams with layout primitives (horizontal/vertical/grid layouts + auto registration).
  • DiagramRoot wrapper that bundles SVGContainer, layout provider, and default layers.
  • Component boxes, subgraph boxes, layer groups, legends, info cards, and template icons.
  • Layout wrappers for common boxes (ComponentBoxWithLayout, SubgraphBoxWithLayout).
  • Connection routing: orthogonal, orthogonal-avoid, straight, and curved.
  • Routing offload to a Web Worker (sync fallback) with deterministic config.
  • Arrow styling per edge (filled, hollow, vee, circle, cross, diamond, diamond-hollow, bar, square, square-hollow).
  • Edge labels + start/end cardinalities.
  • Connection points rendered on the box edge or the connection path.
  • Debug points + debug panel with live payload and copy-to-clipboard.
  • Diagram settings panel (lil-gui) persisted to localStorage with JSON/snippet export.
  • SVG viewer with pan/zoom, fit-on-load, and SVG file or React component sources.
  • Example diagram included (ExampleDiagram).
  • Storybook for browsing components and diagram features.

Installation (workspace)

This package is meant for local workspace use. Add the dependency:

{
  "dependencies": {
    "@sewdn/diagram-kit": "workspace:*"
  }
}

Styles

Import the diagram styles once in your app:

import "@sewdn/diagram-kit/styles.css";

The settings panel imports lil-gui styles internally. The app is expected to provide Tailwind utilities and CSS variables for theme colors (e.g. --foreground, --muted-foreground, --destructive, --primary).

Quick Start

import {
  DiagramSettingsProvider,
  DiagramSettingsPanel,
  SvgViewer,
  ExampleDiagram,
} from "@sewdn/diagram-kit";

export function DiagramPage() {
  return (
    <DiagramSettingsProvider>
      <DiagramSettingsPanel className="diagram-gui-container" />
      <div id="diagram-debug-panel" className="diagram-debug-host" />
      <div style={{ height: 720 }}>
        <SvgViewer svgComponent={ExampleDiagram} fitOnLoad />
      </div>
    </DiagramSettingsProvider>
  );
}

Per-diagram settings

The controls panel can export the current configuration. Use the Export → Copy diagram snippet button or add settings manually to a diagram registry:

diagramSettings: {
  routingMode: 'worker',
  routingAlgorithm: 'orthogonal',
  minStraightLength: 24,
  showArrows: true,
  arrowSize: 10,
  showConnectionLabels: true,
},

Storybook

From this package:

bun run storybook

API Reference

SvgViewer

type SvgViewerProps = {
  svgPath?: string;
  svgComponent?: React.ComponentType;
  viewBox?: string;
  className?: string;
  fitOnLoad?: boolean;
};
  • svgPath: URL to an SVG asset.
  • svgComponent: React diagram component (use SVGContainer contentOnly).
  • viewBox: Override viewBox when the SVG has none.
  • fitOnLoad: Auto fit diagram to viewer after load.

DiagramSettings

type DiagramSettings = {
  showConnections: boolean;
  routingMode: "worker" | "sync" | "off";
  routingAlgorithm: "orthogonal" | "orthogonal-avoid" | "straight" | "curved";
  shortDistanceThreshold: number;
  gridSize: number; // legacy (unused by routing)
  obstaclePadding: number;
  portOffset: number;
  minStraightLength: number;
  turnPenalty: number;
  cornerRadius: number;
  snapToGrid: "axis" | "direct"; // legacy (unused by routing)
  avoidObstacles: boolean;
  avoidConnections: boolean;
  debugPoints: boolean;
  showConnectionPoints: boolean;
  connectionPointSize: number;
  connectionPointLocation: "box" | "edge";
  showArrows: boolean;
  arrowSize: number;
  showConnectionLabels: boolean;
  showDebugPanel: boolean;
  fitOnLoad: boolean;
};

DiagramSettingsProvider

type DiagramSettingsProviderProps = {
  initialSettings?: Partial<DiagramSettings>;
  children: React.ReactNode;
};

DiagramSettingsPanel

type DiagramSettingsPanelProps = {
  className?: string;
};

The panel persists settings in localStorage and provides JSON/snippet export buttons.

Layout primitives

LayoutProvider
LayoutItem({ id, x, y, width, height, children })
HorizontalLayout({ x, y, spacing?, align?, children })
VerticalLayout({ x, y, spacing?, align?, children })
GridLayout({ x, y, columns, rowHeight, columnWidth, gapX?, gapY?, children })

Use LayoutProvider to auto-register positions for connections.

Boxes & groups

ComponentBox

type ComponentBoxProps = {
  x: number;
  y: number;
  width: number;
  height: number;
  title: string;
  subtitle?: string;
  items?: string[];
  variant?:
    | "component"
    | "primary"
    | "accent"
    | "muted"
    | "legacy"
    | "new"
    | "success"
    | "migrated"
    | "decommissioned"
    | "placeholder"
    | "gateway"
    | "adapter";
  badge?: { text: string; variant: "new" | "success" | "migrating" | "decom" };
  template?: "frontend" | "service" | "api" | "storage";
};

Template shortcuts:

  • FrontendComponentBox, ServiceComponentBox, ApiComponentBox, StorageComponentBox

SubgraphBox

type SubgraphBoxProps = {
  x: number;
  y: number;
  width: number;
  height: number;
  title: string;
  subtitle?: string;
  entities?: Array<{ name: string; isKey?: boolean }>;
  source?: string;
  variant?: "subgraph" | "adapter" | "component" | "new";
  badge?: { text: string; variant: "new" | "success" | "migrating" | "decom" };
};

LayerGroup

type LayerGroupProps = {
  x: number;
  y: number;
  width: number;
  height: number;
  title: string;
  children: React.ReactNode;
};

Legend

type LegendItemProps = {
  variant:
    | "component"
    | "primary"
    | "accent"
    | "new"
    | "legacy"
    | "migrated"
    | "decommissioned"
    | "subgraph"
    | "adapter";
  label: string;
};
type LegendProps = { x: number; y: number; title?: string; items: LegendItemProps[] };

DiagramTitle

type DiagramTitleProps = { x: number; y: number; title: string; subtitle?: string };

InfoBox

type InfoBoxProps = {
  x: number;
  y: number;
  width: number;
  height: number;
  title: string;
  sections: Array<{ title: string; items: string[] }>;
  variant?: "muted" | "component" | "accent";
};

Connections

EdgeConnection

type EdgeConnectionProps = {
  id?: string;
  from: string;
  to: string;
  variant?: "default" | "data" | "sync" | "adapter" | "readonly";
  edgeCode?: string; // e.g. "BT" (bottom -> top)
  arrowStyle?:
    | "filled"
    | "hollow"
    | "vee"
    | "circle"
    | "cross"
    | "diamond"
    | "diamond-hollow"
    | "bar"
    | "square"
    | "square-hollow"
    | "none";
  arrowPlacement?: "none" | "start" | "end" | "both";
  fromSide?: "top" | "bottom" | "left" | "right";
  toSide?: "top" | "bottom" | "left" | "right";
  fromOffset?: number;
  toOffset?: number;
  label?: string;
  startCardinality?: string;
  endCardinality?: string;
};

ConnectionLayer

type ConnectionLayerProps = {
  connections?: EdgeConnection[];
  shortDistanceThreshold?: number;
  routing?: { mode?: "worker" | "sync" | "off"; config?: RoutingConfig };
  debug?: boolean;
};

ConnectionPointsLayer

type ConnectionPointsLayerProps = {
  renderIn: "connections" | "components";
  connections?: EdgeConnection[];
  config?: RoutingConfig;
};

RoutingConfig

type RoutingConfig = {
  gridSize?: number; // legacy (unused by routing)
  obstaclePadding?: number;
  portOffset?: number;
  minStraightLength?: number;
  turnPenalty?: number;
  shortDistanceThreshold?: number;
  algorithm?: "orthogonal" | "orthogonal-avoid" | "straight" | "curved";
  cornerRadius?: number;
  snapToGrid?: "axis" | "direct"; // legacy (unused by routing)
  avoidObstacles?: boolean;
  avoidConnections?: boolean;
};

SVGContainer

type SVGContainerProps = {
  viewBox: string;
  width?: number;
  height?: number;
  children: React.ReactNode;
  className?: string;
  contentOnly?: boolean;
};

When rendered inside SvgViewer, set contentOnly to true.

Example diagrams included

  • ExampleDiagram