Skip to main content
The page factories build three primitive elements: text, rectangles, and images. Each is built with a typed options object and then added to the page or a container. An element joins the vertical flow unless it carries a position, which makes it explicit and absolute.

Text

string
required
The text to render.
StyleProperties
Color, font family, size, weight, alignment, padding, and other style fields.
string
A name a theme can target to apply default styles.
number
A fixed width for the text box. Without one, the text takes its intrinsic width.
{ x: number; y: number }
Absolute coordinates. With a position the element is explicit and leaves the flow.
boolean
Overrides the document level markdown setting for this one element.
number
Draw order among overlapping elements within the same parent.

Rectangles

Rectangle colors come from style.background_color or from a shape_style with fill_color and stroke_color. Use stroke_width for the border thickness and border_radius for rounded corners.

Images

The name references an image registered with load_image_sync. Register the file first, then reference it by name.

Text, rectangles, and images together

A position makes an element explicit and absolute on the page. Without one it joins the vertical flow.

Overlay children and z index

Any element can own overlay children built with element.text, element.rect, element.image, or element.create_container. Children are positioned relative to the parent’s top left corner and render on top of it, sorted by z index.
Within the same parent, elements render in ascending z index order regardless of declaration order.

Layout

Arrange elements with flow and flex containers.

Themes

Style elements by type and classname.