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
| Property | Type | Default | Meaning |
|---|---|---|---|
type | string | required | Node kind; unknown kinds do not automatically become drawable shapes. |
id | string | generated | Insert/Copy/Replace always mint fresh IDs, ignoring supplied IDs; Update cannot change them. |
name | string | unset | Readable label; created maps names to IDs, with the last creation winning duplicate names. |
x, y | number | 0 | Design pixels relative to the parent in absolute layout; ignored for children in layout flow. |
width, height | number / string | by kind | Fixed pixels, “fill_container”, “fit_content”, optionally with an (n) fallback; see sizing rules. |
enabled | boolean | true | false hides a node and removes it from parent layout flow; its size can still be read. |
opacity | number | 1 | Node/subtree opacity; use 0–1. |
rotation | number | 0 | Degrees, positive counter-clockwise; layout bounds are the rotated axis-aligned box. |
flipX, flipY | boolean | false | Flip painting around the node origin without recomputing layout. |
theme | Record<string, string> | inherited | Overrides theme axes for this subtree; does not inherit style properties. |
reusable | boolean | false | Marks a component; Copy creates a ref instance. |
fill, stroke, effect | value or array | none | Painting 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.
| Property | Type | Default | Meaning |
|---|---|---|---|
children | Node[] | [] | 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. |
gap | number | 0 | Design-pixel spacing between adjacent in-flow children. |
padding | number / [number, number] / [number, number, number, number] | 0 | One value; [vertical, horizontal]; [top, right, bottom, left]; applies to horizontal/vertical layout. |
justifyContent | string | start | Main-axis alignment: start, center, end, space_between, space_around. |
alignItems | string | start | Cross-axis alignment: start, center, end; use fill_container on children to stretch. |
layoutPosition | "absolute" | unset | Set on a child to remove it from flow and use x/y. |
clip | boolean | false | Only frame clip:true clips descendant painting to its rounded boundary. |
cornerRadius | number / [number, number, number, number] | 0 | Uniform radius or [top-left, top-right, bottom-right, bottom-left], capped at half the shorter side. |
placeholder | boolean | false | Placeholder 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.
| Property | Type | Default | Meaning |
|---|---|---|---|
children | Node[] | [] | Ordered child nodes. |
width, height | Ignored | Content-based | Bounds come from visible child positions and sizes. |
layout, clip, fill, stroke | Unsupported | None | Groups 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.
| Property | Type | Default | Meaning |
|---|---|---|---|
width, height | Size | 0 | Use the common size forms. |
cornerRadius | Number or four-value array | 0 | As for frame: top-left, top-right, bottom-right, bottom-left. |
fill, stroke, effect | Paint properties | None | Use the paint objects below; children are unsupported. |
ellipse
| Property | Type | Default | Meaning |
|---|---|---|---|
innerRadius | number | 0 | Inner-radius ratio from 0–1; 0 is solid. |
startAngle | number | 0 | Degrees counter-clockwise from the right. |
sweepAngle | number | 360 | Arc sweep clamped to −360…360 degrees. |
polygon
| Property | Type | Default | Meaning |
|---|---|---|---|
polygonCount | number | 3 | Rounded and clamped to at least 3. |
cornerRadius | number | 0 | Corner path effect on fills; rounded strokes are not guaranteed. |
path
| Property | Type | Default | Meaning |
|---|---|---|---|
geometry | string | none | SVG 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
| Property | Type | Default | Meaning |
|---|---|---|---|
content | string | "" | Plain text; rich-text run arrays are not supported. |
fontFamily | string | "Inter" → Geist | Only the three font families below are loaded; family is not inherited from the parent. |
fontSize | number | 14 | Design pixels. |
fontWeight | number / string | 400 | normal=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. |
lineHeight | number | font metrics | Positive multiplier, not pixels; each line height is rounded to a whole pixel. |
letterSpacing | number | 0 | Design-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, strikethrough | boolean | false | Underline and strikethrough. |
fill | Fill / Fill[] | none | Must be set for text to be visible. |
icon / icon_font
| Property | Type | Default | Meaning |
|---|---|---|---|
library | string | "lucide" | Only lucide is supported; other libraries/unknown names show a placeholder. |
icon | string | iconName or "" | Lucide icon name; iconName is an alias. |
width, height | Size | 0 | Set explicitly; 24×24 icons scale proportionally and center in the box. |
fill | Fill / Fill[] | "#000000" | Icon stroke color; stroke width is 2 in icon space. |
ref
| Property | Type | Default | Meaning |
|---|---|---|---|
ref | string | required | Existing source node ID; a missing source raises UNKNOWN_REF. |
descendants | Record<string, object> | {} | Override by source descendant ID or unique name; an object containing type replaces the node. |
...rootProperties | object | source root properties | Instance root properties override the source root; reusable is not copied. |
note / prompt / context / browser / script
| Property | Type | Default | Meaning |
|---|---|---|---|
content | string | none | Single-line text for note/prompt/context; browser/script do not paint content. |
fontSize | number | 13 | Note/prompt/context text size; text uses Noto Sans SC 400 and fixed dark gray. |
fill | Fill / Fill[] | by kind | note #FEF3C7, prompt #EDE9FE, context #E0F2FE, browser #F4F4F5; script has no default fill. |
width, height | Size | 0 | Set 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.
| Font | Available weights |
|---|---|
| Geist | 400, 500, 600, 700 |
| Geist Mono | 400, 500, 600 |
| Noto Sans SC | 400, 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.
| Property | Type | Default | Meaning |
|---|---|---|---|
fill | Fill / Fill[] | none | Layers paint in array order. |
stroke | Fill / Fill[] | none | Stroke paint, not a {color,width} object. |
strokeWidth | number / {top?, right?, bottom?, left?} | 1 | Uniform 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. |
effect | Effect / Effect[] | none | One effect or an array; enabled:false disables an effect. |
A Fill is "#3366FF", {type:"color",color:"#3366FF"}, or an object described below.
| Property | Type | Default | Meaning |
|---|---|---|---|
type | "color" / "gradient" / "image" | required | Object fill type; colors can also be hexadecimal strings. |
enabled | boolean | true | false skips this fill. |
color | string | none | type: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. |
rotation | number | 0 | Linear rotates counter-clockwise from up; angular rotates its start; radial ignores rotation. |
opacity | number | 1 | Applied to gradient/image only, 0–1; use color alpha for color objects. |
url | string | none | Platform 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] | none | Image supports axis-aligned crops [a,0,0,d,tx,ty], not arbitrary affine transforms. |
blendMode | string | "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 } ]}| Property | Type | Default | Meaning |
|---|---|---|---|
type | "shadow" / "blur" / "background_blur" | required | shadow supports inner/outer shape shadows, outer only for text/icons; blur blurs the node layer; background_blur applies to shapes only. |
enabled | boolean | true | false skips the effect. |
shadowType | "inner" / "outer" | "outer" | Only for shadow. |
color | string | "#00000040" (approx.) | Shadow defaults to black at alpha 0.25. |
offset | {x: number, y: number} | {x:0,y:0} | Shadow offset in design pixels. |
blur | number | 0 | Shadow blur radius. |
radius | number | 0 | Radius 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.