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

@cosmograph/vis-labels

v0.7.0

Published

Visualization Label Renderer

Readme

Vis Labels is a lightweight, performance-focused library for rendering large numbers of HTML labels with built-in intersection handling. It was created to support scenes with many thousands of overlapping labels while keeping the API small and the rendering model predictable.

It powers label rendering in Cosmograph, the fastest web-based network graph rendering framework.

Why Vis Labels

  • Zero-dependency runtime package.
  • Built for scale, including large sets of intersecting labels.
  • Built-in overlap resolution with weighted label priority.
  • Stable visibility decisions to reduce flicker between frames.
  • Reuses DOM nodes by label id instead of recreating them every draw.
  • Uses cached and estimated label measurements to avoid unnecessary layout work.
  • Supports plain text, custom CSS, and trusted HTML / multi-line labels.
  • Lays text along straight or curved paths, such as the edges between graph nodes.
  • Works both as a batch renderer (LabelRenderer) and as individual labels (VisLabel).
  • Optional style injection, exported stylesheet, click handling, and wheel event forwarding for interactive canvases and graphs.

Quick Start

Install the package:

npm install @cosmograph/vis-labels

Create HTML div element and render labels:

import { LabelRenderer } from '@cosmograph/vis-labels'

const div = document.querySelector('#labels')  
const renderer = new LabelRenderer(div)

renderer.setLabels([
  { id: 'monster', text: '👾', x: 100, y: 50, opacity: 1 },
  { id: 'alien', text: '👽', x: 50, y: 150, opacity: 1 },
  { id: 'ufo', text: '🛸', x: 150, y: 150, opacity: 1 },
])
renderer.draw()

Or create single Vis label:

import { VisLabel } from '@cosmograph/vis-labels'
const div = document.querySelector('#labels')

const label = new VisLabel(div, '🐣')
label.setPosition(100, 110)
label.setVisibility(true)
label.setOpacity(1)
label.draw()

React

Import the React wrapper from the react subpath:

import { VisLabels } from '@cosmograph/vis-labels/react'

const labels = [
  { id: 'monster', text: '👾', x: 100, y: 50, opacity: 1 },
  { id: 'alien', text: '👽', x: 50, y: 150, opacity: 1 },
  { id: 'ufo', text: '🛸', x: 150, y: 150, opacity: 1 },
]

export function App (): JSX.Element {
  return (
    <div style={{ position: 'relative', width: 200, height: 200 }}>
      <VisLabels labels={labels} fontSize={18} />
    </div>
  )
}

You can also access the underlying renderer and container via a forwarded ref:

import { useEffect, useRef } from 'react'
import { VisLabels } from '@cosmograph/vis-labels/react'
import type { VisLabelsHandle } from '@cosmograph/vis-labels/react'

export function App (): JSX.Element {
  const labelsRef = useRef<VisLabelsHandle>(null)

  useEffect(() => {
    labelsRef.current?.renderer?.draw()
  }, [])

  return (
    <div style={{ position: 'relative', width: 200, height: 200 }}>
      <VisLabels
        ref={labelsRef}
        labels={[
          { id: 'label', text: 'Hello React', x: 100, y: 110, opacity: 1 },
        ]}
        fontSize={16}
      />
    </div>
  )
}