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

svglayout

v0.1.0

Published

Flex and Grid layout engine for SVG — TypeScript-first, zero dependencies

Downloads

156

Readme

SVGLayout

Flex and Grid layout engine for SVG — TypeScript-first, zero dependencies.

CSS layout primitives (flexbox, grid, spring animation, constraint solving) for SVG coordinate space. Drop it into any D3 chart, diagram tool, SVG UI renderer, or canvas-based app.

Install

npm install svglayout

Quick start

import { computeFlex, computeGrid, SVGLayout } from 'svglayout';
import type { FlexItem, GridItem } from 'svglayout';

// ── Flex ──────────────────────────────────────────────────────
const items: FlexItem[] = [
  { w: 80, h: 60 },
  { w: 120, h: 60, grow: 1 },  // absorbs remaining space
  { w: 80, h: 60 },
];

const positions = computeFlex(items, 600, 120, {
  direction:      'row',
  justifyContent: 'flex-start',
  alignItems:     'center',
  gap:            16,
  padding:        20,
});
// → [{ x, y, w, h, line }, ...]

// ── Grid ──────────────────────────────────────────────────────
const gridItems: GridItem[] = [
  { colSpan: 2 }, {}, {},
  {}, { colSpan: 2 },
];

const grid = computeGrid(gridItems, 900, {
  columns:   3,
  rowHeight: 100,
  colGap:    16,
  rowGap:    16,
  padding:   24,
});
// → [{ x, y, w, h, col, row }, ...]

API

| Export | Description | |---|---| | computeFlex(items, w, h, opts) | Flex layout with wrap, grow, shrink, align-content | | computeGrid(items, w, opts) | Grid with fr units, spans, explicit placement | | resolveTree(root) | Nested flex+grid layout tree → absolute coords | | LayoutAnimator | Spring physics tweening between layout states | | generateDevTools(tree, opts) | SVG overlay for layout debugging | | solveConstraints(items, constraints) | Cassowary-style constraint solver | | Constraints | Fluent constraint builder (rightOf, below, alignTop…) | | SVGLayout | Namespace wrapping all of the above |

Features

  • flex-wrap + align-content (multi-line flex)
  • flex-grow / flex-shrink / flex-basis
  • ✅ Grid fr units + colSpan / rowSpan
  • ✅ Explicit grid placement (colStart / rowStart)
  • ✅ Nested layout trees (flex inside grid inside flex…)
  • ✅ Spring animation engine (stiffness / damping / mass)
  • ✅ DevTools overlay (boxes, axes, gaps, labels)
  • ✅ Constraint solver (drag propagation, required/strong/weak)
  • ✅ Zero runtime dependencies
  • ✅ Full TypeScript types

License

MIT