Gum

Gum describes diagrams with JSX and renders them as SVG. The reference pages describe the elements, layout rules, and rendering APIs.

With the CLI installed, start with gum docs for an authoring walkthrough. The command includes this reference corpus offline: search with gum docs search "axis labels", retrieve a page with gum docs get elements/Plot, or print runnable source with gum docs example elements/Plot.

Start here

  1. Use TextBox or TextFrame for padded document content.
  2. Set its width, height, and font-size directly; hosts add the Page viewport around a bare root.
  3. Arrange content with TextCol, HStack, or Group.
  4. Add shapes and Text.

Use Positioning to place labels, shapes, and containers with pos and anchor in local or data coordinates.

TextBox, TextFrame, and TextCol are content-sized by default. Use width="fill" when a document should occupy the available width; established widths pass to automatically sized content, respecting explicit child sizes. Box, Frame, and VStack provide primitives that size to their content by default.

Each page has a matching executable example. Download or edit the linked JSX; it needs no imports when evaluated by the Gum CLI.

Three rules worth learning

  • Raw length numbers are fractions. Write px(100) for 100 pixels or em(2) for two local font sizes. A raw width={100} means 100 times the established parent width, not 100 pixels. See Units.
  • Stack growth and shrinkage are explicit. A column can measure aspect figures from a supplied width, but does not infer a shared width from their combined height. See Sizing and Stack.
  • Text keeps its font size during layout. Standalone formulas shrink when needed. Put fit on a composed drawing to scale it as a whole, including its glyphs and strokes.

There is no browser DOM or React runtime behind these elements. JSX constructs immutable descriptions; a layout pass creates geometry; SVG rendering serializes that result. The rendering API exposes each stage separately.

Run the example

With gum-jsx installed globally, save the example below as hello.jsx:

The first command uses kitty graphics. See CLI for PNG, tree, JSON, viewport overrides, and other terminal options.