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

@gum-jsx/react

v2.0.0

Published

React bindings for Gum.

Readme

@gum-jsx/react

React bindings for Gum. The package provides a custom renderer for headless SVG generation and a <Gum> component for React DOM applications.

See the Gum project for getting started and the package overview. Compatible React and React DOM versions are listed in the peer dependencies.

React DOM

import { px } from '@gum-jsx/core'
import { createGumRoot, Gum, GUM } from '@gum-jsx/react'

const { Circle, HStack, Rect, Text } = GUM

export default function Scene() {
  return (
    <HStack gap={px(20)}>
      <Rect fill="blue" />
      <Circle fill="red" />
      <Text>Hello</Text>
    </HStack>
  )
}

export function Figure() {
  return (
    <Gum size={{ width: 640, height: 360 }}>
      <Scene />
    </Gum>
  )
}

The GUM components belong inside <Gum> or a Gum root. They describe Gum elements through the custom renderer. Use underscore prop names such as font_size and stroke_width in React TSX.

Use pos={[x, y]} or pos={{x, y}} for placement. Projected Graph children also accept arbitrary numeric records. Projection callbacks receive the complete record and return a record with final x and y, or null to hide a point:

<GUM.Graph
  xlim={[-1, 1]} ylim={[-1, 1]}
  projection={({ theta, r }) => ({ x: r * Math.cos(theta), y: r * Math.sin(theta) })}
>
  <GUM.Points
    points={[{ theta: Math.PI / 4, r: 0.8 }]}
    point_size={({ r }) => px(8 * r)}
  />
  <GUM.Text pos={{ theta: Math.PI / 4, r: 1 }} anchor="center">45°</GUM.Text>
</GUM.Graph>

Callbacks retain contextual TypeScript types, including Points fields inferred from its input records. React elements also work in element-valued props and callback results. GeoMap children use {lon, lat} in degrees, with [longitude, latitude] and {x, y} aliases. See the coordinate migration for placement, local lengths, and geographic naming rules.

Headless SVG

Using Scene from the example above, create a root directly:

const root = createGumRoot({ size: [640, 360], theme: 'dark' })
await root.loadFonts()
root.render(<Scene />)
console.log(root.getSvg())
root.unmount()

A numeric size is the maximum extent on either axis. Content reflows within those offers, then the completed figure scales down uniformly if necessary, including both dimensions, fonts, and strokes. Pass [width, height] or { width, height } for exact viewport dimensions instead.

Fonts and emoji

Text is outlined, so figures need no page fonts. Emoji are the exception: core measures them with a bundled metrics face and keeps them as live SVG text in the family Noto Color Emoji. <Gum> renders inline, so the page's own @font-face rule paints them. Without one, the viewer's emoji font is used, with each emoji centered in its measured advance.

@font-face {
  font-family: 'Noto Color Emoji';
  src: url('@fontsource/noto-color-emoji/files/noto-color-emoji-emoji-400-normal.woff2') format('woff2');
}

Use that complete file. The package's unicode-range slices are OpenType-SVG only, which Chrome does not paint. Keep the family out of the page's own font stacks, and the browser fetches it only once a figure contains an emoji.

A custom fonts value is an effect dependency of <Gum>. Create it once, outside the component or in useMemo, or every render rebuilds the root and reloads fonts.

GUM includes the core and math element classes and GUM.GeoMap from @gum-jsx/maps. Import map data helpers such as world_countries and us_states from @gum-jsx/maps. Wrap an application-defined element class with createGumComponent, or pass a named elements registry to a root.

Command line

Save the first example as figure.tsx. The gum-react command renders its default-exported Scene component to SVG.

bun run --silent gum-react figure.tsx --size 800 --theme dark > figure.svg

The CLI's numeric --size likewise sets the maximum output dimension. It accepts --cwd to choose the base directory for relative ?raw imports and passes the selected theme to the exported component.

Development

Run bun run test and bun run typecheck from this package directory.