Skip to content
中文

Node reference

Pass these objects to Insert(parent, node). This page lists the .pen 2.21 properties Praxis actually interprets. Unknown fields may survive storage without taking effect. Lengths are design pixels; angles are degrees.

Common properties

PropertyTypeDefaultMeaning
typestringrequiredNode kind; unknown kinds do not automatically become drawable shapes.
idstringgeneratedInsert/Copy/Replace always mint fresh IDs, ignoring supplied IDs; Update cannot change them.
namestringunsetReadable label; created maps names to IDs, with the last creation winning duplicate names.
x, ynumber0Design pixels relative to the parent in absolute layout; ignored for children in layout flow.
width, heightnumber / stringby kindFixed pixels, “fill_container”, “fit_content”, optionally with an (n) fallback; see sizing rules.
enabledbooleantruefalse hides a node and removes it from parent layout flow; its size can still be read.
opacitynumber1Node/subtree opacity; use 0–1.
rotationnumber0Degrees, positive counter-clockwise; layout bounds are the rotated axis-aligned box.
flipX, flipYbooleanfalseFlip painting around the node origin without recomputing layout.
themeRecord<string, string>inheritedOverrides theme axes for this subtree; does not inherit style properties.
reusablebooleanfalseMarks a component; Copy creates a ref instance.
fill, stroke, effectvalue or arraynonePainting properties for the node kinds described below; see paint object shapes.

Node kinds

frame

Container with a painted background, stroke and effects, supporting the layout properties below.

PropertyTypeDefaultMeaning
childrenNode[][]Only frame/group store children; use Insert to append and Replace to replace a subtree.
layout"none" / "horizontal" / "vertical""horizontal"Frame layout direction; groups always use absolute layout.
gapnumber0Design-pixel spacing between adjacent in-flow children.
paddingnumber / [number, number] / [number, number, number, number]0One value; [vertical, horizontal]; [top, right, bottom, left]; applies to horizontal/vertical layout.
justifyContentstringstartMain-axis alignment: start, center, end, space_between, space_around.
alignItemsstringstartCross-axis alignment: start, center, end; use fill_container on children to stretch.
layoutPosition"absolute"unsetSet on a child to remove it from flow and use x/y.
clipbooleanfalseOnly frame clip:true clips descendant painting to its rounded boundary.
cornerRadiusnumber / [number, number, number, number]0Uniform radius or [top-left, top-right, bottom-right, bottom-left], capped at half the shorter side.
placeholderbooleanfalsePlaceholder marker shown in summaries; does not generate content or change layout.

group

Container using common properties and children. Always positions children absolutely using x/y and sizes to content; its width/height and layout are ignored. It does not paint fill/stroke or clip children.

PropertyTypeDefaultMeaning
childrenNode[][]Ordered child nodes.
width, heightIgnoredContent-basedBounds come from visible child positions and sizes.
layout, clip, fill, strokeUnsupportedNoneGroups do not use flow layout, paint their own shape or clip descendants.

rectangle

Uses common properties, cornerRadius (as for frame) and paint properties. Width/height default to 0, there is no default fill, and children are not allowed.

PropertyTypeDefaultMeaning
width, heightSize0Use the common size forms.
cornerRadiusNumber or four-value array0As for frame: top-left, top-right, bottom-right, bottom-left.
fill, stroke, effectPaint propertiesNoneUse the paint objects below; children are unsupported.

ellipse

PropertyTypeDefaultMeaning
innerRadiusnumber0Inner-radius ratio from 0–1; 0 is solid.
startAnglenumber0Degrees counter-clockwise from the right.
sweepAnglenumber360Arc sweep clamped to −360…360 degrees.

polygon

PropertyTypeDefaultMeaning
polygonCountnumber3Rounded and clamped to at least 3.
cornerRadiusnumber0Corner path effect on fills; rounded strokes are not guaranteed.

path

PropertyTypeDefaultMeaning
geometrystringnoneSVG path data; invalid/missing data falls back to rectangular geometry.
viewBox[number, number, number, number]tight path bounds[x, y, width, height], scaled to the node width/height.
fillRule"nonzero" / "evenodd""nonzero"Path fill rule.

Ellipse, polygon and path also use common sizing and paint properties; sizes default to 0, there is no default fill, and children are not allowed.

text

PropertyTypeDefaultMeaning
contentstring""Plain text; rich-text run arrays are not supported.
fontFamilystring"Inter" → GeistOnly the three font families below are loaded; family is not inherited from the parent.
fontSizenumber14Design pixels.
fontWeightnumber / string400normal=400, bold=700; numeric values/strings select the nearest available weight, ties favor heavier.
textGrowth"auto" / "fixed-width" / "fixed-width-height""auto"See text sizing rules.
lineHeightnumberfont metricsPositive multiplier, not pixels; each line height is rounded to a whole pixel.
letterSpacingnumber0Design-pixel spacing per grapheme; can be negative.
textAlign"left" / "center" / "right" / "justify""left"Horizontal alignment; justify expands internal spaces on nonfinal lines only.
textAlignVertical"top" / "middle" / "bottom""top"Vertical painting alignment only for fixed-width-height.
underline, strikethroughbooleanfalseUnderline and strikethrough.
fillFill / Fill[]noneMust be set for text to be visible.

icon / icon_font

PropertyTypeDefaultMeaning
librarystring"lucide"Only lucide is supported; other libraries/unknown names show a placeholder.
iconstringiconName or ""Lucide icon name; iconName is an alias.
width, heightSize0Set explicitly; 24×24 icons scale proportionally and center in the box.
fillFill / Fill[]"#000000"Icon stroke color; stroke width is 2 in icon space.

ref

PropertyTypeDefaultMeaning
refstringrequiredExisting source node ID; a missing source raises UNKNOWN_REF.
descendantsRecord<string, object>{}Override by source descendant ID or unique name; an object containing type replaces the node.
...rootPropertiesobjectsource root propertiesInstance root properties override the source root; reusable is not copied.

note / prompt / context / browser / script

PropertyTypeDefaultMeaning
contentstringnoneSingle-line text for note/prompt/context; browser/script do not paint content.
fontSizenumber13Note/prompt/context text size; text uses Noto Sans SC 400 and fixed dark gray.
fillFill / Fill[]by kindnote #FEF3C7, prompt #EDE9FE, context #E0F2FE, browser #F4F4F5; script has no default fill.
width, heightSize0Set a visible size; content does not size the node.

These kinds paint static shapes only. Browser is not an interactive browser; script does not execute code. None accepts children.

Sizing and layout

Sizes have three basic forms: a fixed number such as 240; "fit_content" based on visible content; and "fill_container" using space assigned by the parent. "fit_content(240)" supplies a fallback when content cannot determine the size, not a minimum. "fill_container(240)" supplies a natural-size fallback when no parent assigns space. Numeric strings also parse as fixed sizes.

Frames default to layout: "horizontal" and fit-content width/height. An empty frame with layout: "none" instead defaults to 0 in both dimensions. Groups always fit content. Shapes, icons and static annotations default to 0 width/height.

Horizontal/vertical layout has one axis and never wraps. The main axis subtracts padding, gaps and fixed/content sizes, then divides nonnegative remaining space equally between fill children. Cross-axis fill occupies the inner dimension. In-flow x/y are ignored. A child with layoutPosition: "absolute" is excluded from flow sizing and uses x/y; its fill dimensions occupy the parent’s entire box without subtracting padding. layout: "none" also uses absolute positioning.

A fit parent whose same-axis size depends only on fill children produces FIT_FILL_CYCLE. Fill without a fallback contributes 0 to natural sizing; children collapse to 0 when no space remains after gaps. Gaps and padding can still keep the parent nonzero. Give the parent a fixed size, a fit fallback, or a child that determines content size on that axis.

There is no margin, percentage sizing, viewport unit, calc, wrapping, flex grow/shrink weight, min/max size or scrolling container. clip affects painting only. Clipping diagnostics can appear with clip:false because they check overflow beyond the parent frame.

Positive rotation is counter-clockwise. Absolute nodes rotate around their top-left corner, so bounds can move left or above x/y. Flow positions the rotated bounding box. Nodes with enabled:false neither contribute space to parent layout nor paint.

Text sizing and fonts

textGrowth: "auto" ignores width/height and does not wrap to a width (explicit newlines still apply); width is floor(w)+1 of the measured width. "fixed-width" wraps at the supplied width and grows in height. "fixed-width-height" uses both supplied dimensions and allows vertical alignment. A fixed text height does not itself clip text; frame clip can clip descendants.

Text requires fill. Styles do not inherit from parents. lineHeight multiplies the font size: fontSize: 20, lineHeight: 1.5 gives 30-pixel lines. Omission uses font metrics.

FontAvailable weights
Geist400, 500, 600, 700
Geist Mono400, 500, 600
Noto Sans SC400, 500, 700

Family names containing SC/CJK map to Noto Sans SC; otherwise names containing Mono map to Geist Mono; all other names map to Geist, using case-insensitive matching. Weight selects the nearest value, ties favoring heavier. Missing glyphs try Noto Sans SC, then Geist, before retaining the primary font. Custom font uploads, italic and rich-text style runs are unsupported.

Fills, strokes and effects

Use stroke: "#E5484D", strokeWidth: 2 and strokeAlignment: "inner"; per-side widths use strokeWidth: { top: 1 }. The old Pencil form stroke: { fill: "#E5484D", thickness: 2, align: "inside" } is automatically rewritten on writes and imports: fill becomes stroke, thickness becomes strokeWidth, inside/outside become inner/outer, and center stays center. Explicit strokeWidth/strokeAlignment values take precedence. A fill-only legacy stroke leaves strokeWidth absent and uses the default width.

Undefined property names produce UNKNOWN_PROPERTY warnings. For example, replace textDecoration with strikethrough: true or underline: true. Top-level ref override keys, metadata contents and internal keys starting with __ are exempt. Each execute returns at most 20 deduplicated warnings.

PropertyTypeDefaultMeaning
fillFill / Fill[]noneLayers paint in array order.
strokeFill / Fill[]noneStroke paint, not a {color,width} object.
strokeWidthnumber / {top?, right?, bottom?, left?}1Uniform width or per-side widths; missing sides are 0, painted as straight edge bands.
strokeAlignment"inner" / "center" / "outer""center"Path strokes always center; other shapes honor alignment.
strokeLinecap"butt" / "round" / "square""butt"Caps for uniform strokes.
strokeLinejoin"miter" / "round" / "bevel""miter"Joins for uniform strokes.
effectEffect / Effect[]noneOne effect or an array; enabled:false disables an effect.

A Fill is "#3366FF", {type:"color",color:"#3366FF"}, or an object described below.

PropertyTypeDefaultMeaning
type"color" / "gradient" / "image"requiredObject fill type; colors can also be hexadecimal strings.
enabledbooleantruefalse skips this fill.
colorstringnonetype:color uses #RGB, #RGBA, #RRGGBB, #RRGGBBAA; CSS color names/rgb() are unsupported.
gradientType"linear" / "radial" / "angular""linear"Only for type:gradient.
colors{color: string, position: number}[][]Gradient stops; use positions from 0–1.
center{x: number, y: number}{x:0.5,y:0.5}Gradient center normalized to the node bounds.
size{width: number, height: number}{width:1,height:1}Relative radial diameters; linear uses height as its length.
rotationnumber0Linear rotates counter-clockwise from up; angular rotates its start; radial ignores rotation.
opacitynumber1Applied to gradient/image only, 0–1; use color alpha for color objects.
urlstringnonePlatform file ID: file- followed by 24 base62 characters; relative paths and HTTP URLs are unsupported.
mode"cover" / "contain" / "stretch""cover"Image scaling; cover/contain center proportionally, stretch scales independently.
transform[number, number, number, number, number, number]noneImage supports axis-aligned crops [a,0,0,d,tx,ty], not arbitrary affine transforms.
blendModestring"normal"See the supported list below; unknown values use normal.

Object forms (property fragments, not standalone scripts):

{
"fill": { "type": "gradient", "gradientType": "linear", "rotation": 90, "colors": [{ "color": "#FFFFFF", "position": 0 }, { "color": "#3366FF", "position": 1 }] },
"stroke": "#CCCCCC",
"strokeWidth": { "top": 1, "bottom": 2 },
"strokeAlignment": "inner",
"effect": [
{ "type": "shadow", "shadowType": "outer", "color": "#00000040", "offset": { "x": 0, "y": 4 }, "blur": 12 },
{ "type": "blur", "radius": 2 }
]
}
PropertyTypeDefaultMeaning
type"shadow" / "blur" / "background_blur"requiredshadow supports inner/outer shape shadows, outer only for text/icons; blur blurs the node layer; background_blur applies to shapes only.
enabledbooleantruefalse skips the effect.
shadowType"inner" / "outer""outer"Only for shadow.
colorstring"#00000040" (approx.)Shadow defaults to black at alpha 0.25.
offset{x: number, y: number}{x:0,y:0}Shadow offset in design pixels.
blurnumber0Shadow blur radius.
radiusnumber0Radius for blur / background_blur.

Supported blendMode values: normal, darken, multiply, colorBurn, lighten (light), screen, colorDodge, overlay, softLight, hardLight, difference, exclusion, hue, saturation, color, luminosity, linearBurn, linearDodge.

linearBurn approximates multiply; linearDodge uses additive blending. mesh_gradient does not support full mesh/control-point semantics: explicit points enable only a four-corner color approximation; without points it paints nothing. shader is unsupported and displays a placeholder. Shadow spread is unsupported. Missing or unreadable images display a gray placeholder.

Image fills

Upload the image with praxis.file.uploadFile, then set fill to { type: "image", url: file.id, mode: "cover" }. The file must belong to the canvas organization. Both the browser viewer and PNG screenshots display the image; the canvas stores its file ID only. contain preserves the whole image; stretch fills the box without preserving aspect ratio.

In codemode with Praxis access, first put a PNG at /tmp/photo.png on the agent computer, then run this program:

import { praxis } from "praxis";
import { readFile } from "node:fs/promises";
export default async () => {
const file = await praxis.file.uploadFile(
new Blob([await readFile("/tmp/photo.png")], { type: "image/png" }),
{ filename: "photo.png", purpose: "vision" }
);
const canvas = await praxis.canvas.canvases.create({ body: { name: "Photo canvas" } });
const script = String.raw`photo = Insert(document, {
type: "rectangle", name: "Photo", width: 240, height: 160,
fill: { type: "image", url: imageFileId, mode: "cover" }
});
TakeScreenshot([photo]);`;
const result = await praxis.canvas.canvases.execute({
path: { canvas_id: canvas.id },
body: { script: `const imageFileId = ${JSON.stringify(file.id)};\n${script}`, expected_version: canvas.version }
});
const images = await praxis.canvas.canvases.images.list({
path: { canvas_id: canvas.id },
query: { ids: result.created.Photo, format: "png", scale: 1 }
});
return { file_id: file.id, viewer_url: result.viewer_url, image: images.images[result.created.Photo], warnings: result.warnings };
};

The result includes file_id, a viewer_url, a PNG data URL in image, and empty warnings. A non-file URL produces UNSUPPORTED_IMAGE_URL without rejecting the node; it displays a gray placeholder. A screenshot loads at most 32 unique images, each at most 8 MiB and at most 24 MiB total; images beyond those limits stay gray.

Variables, themes and components

Define variables as {type:"color"|"number"|"string"|"boolean", value: ...} with names without $. An entire property string "$name" resolves a variable; there is no string interpolation. A whole content reference converts to a string; name, id, type and ref do not resolve variables. Themed value arrays use {value, theme:{axis:value}}. The entry matching the most axes wins; ties keep the first entry, and no match uses the first array entry. Each axis defaults to its first registered value; node theme overrides propagate to descendants. Variable aliases recurse through depth 8; beyond that they resolve to undefined.

Set reusable:true on a component. Copy creates a ref for reusable sources; ordinary nodes are deep-copied with fresh IDs. Ref root properties override the component root. Plain descendants objects merge properties; objects containing type replace the node. Unique descendant names can be keys; use source IDs for ambiguous names, and relative ID paths for nested instances. Outer instance overrides win over inner ones. Instance children use instanceId/sourceChildId paths; replacement nodes from Replace are addressed by their new ID alone.

This script creates variables, a component and two instances. Page measures 520 × 112; each instance is 240 wide.

SetVariables({
surface: { type: "color", value: [
{ value: "#FFFFFF", theme: { mode: "light" } },
{ value: "#111111", theme: { mode: "dark" } }
] },
ink: { type: "color", value: "#333333" }
});
const component = Insert(document, {
type: "frame", name: "Card", reusable: true, x: 0, y: -160,
width: 240, height: 80, padding: 16, fill: "$surface"
});
const label = Insert(component, {
type: "text", name: "Label", content: "Default",
fontFamily: "Geist", fontSize: 16, fill: "$ink"
});
const page = Insert(document, {
type: "frame", name: "Page", width: 520, height: 112,
padding: 16, gap: 8, fill: "#EEEEEE", theme: { mode: "light" }
});
const first = Copy(component, page, {
name: "First", width: "fill_container", descendants: { [label]: { content: "First" } }
});
Insert(page, {
type: "ref", ref: component, name: "Second", width: "fill_container",
descendants: { [label]: { content: "Second" } }
});
Get(page, (node, ctx) => Print(node.name, ctx.bounds), { resolveInstances: true });

See script functions for calls and limits and errors for diagnostics.