Skip to content

TextBox

Use textbox when text must stay inside a known rectangle. It wraps deterministically and can shrink or truncate copy so agent-authored labels, callouts, and captions do not escape their boxes.

elements: {
summary: {
id: 'summary',
type: 'textbox',
role: 'callout',
layout: { x: 80, y: 120, width: 360, height: 140 },
props: {
type: 'textbox',
x: 80,
y: 120,
width: 360,
height: 140,
content: 'TextBox wraps generated copy and keeps it within this visual region.',
fontSize: 20,
autoFit: 'shrink',
background: { fill: '$surface', stroke: '$muted' },
},
},
}
PropTypeDefaultDescription
x, ynumberrequiredTop-left corner of the box
width, heightnumberrequiredOuter box dimensions
contentstringrequiredText to display
paddingnumber | { x?: number; y?: number }12, 10Inner text inset
fontSizenumber20Starting font size in pixels
minFontSizenumber10Smallest font size used by autoFit: 'shrink'
fontFamilystring'sans-serif'Font family
fontWeightstring | number'normal'Font weight
lineHeightnumber1.2 * fontSizeLine height; values <= 4 are ratios
align'start' | 'middle' | 'end''start'Horizontal text alignment
verticalAlign'top' | 'middle' | 'bottom''top'Vertical placement of rendered lines
autoFit'none' | 'shrink' | 'truncate''none'How to handle text that exceeds the inner bounds
background{ fill?: string; stroke?: string; strokeWidth?: number; radius?: number }styled defaultBackground rectangle styling

Prefer createTextBoxPreset() or the CLI add-textbox command for generated prose:

Terminal window
npx @elucim/cli add-textbox diagram.elc --id summary --x 80 --y 120 --width 360 --height 140 --text "Bounded copy" --auto-fit shrink --background panel --out diagram.elc --json

Pass --background none when the text should be bounded for layout but drawn without a visible panel.

The helper and CLI default to autoFit: 'shrink' so generated copy stays bounded; the raw primitive defaults to autoFit: 'none'.