Skip to content

Vibe coding a plugin? 😎 Teach your agent Modlumi first. Works with Claude Code, Codex, Cursor and more.

Ui

Draws the widgets of a plugin’s panel or dialog, the same widgets Modlumi’s own panels use. Value widgets take the current value and return it, or the user’s change of it:

state.width = ui.length("Width", state.width, { min: 0.1 });
if (ui.button("Build", { primary: true })) build(state);

Consecutive fields line up in a form, labels on the left. A widget is identified by its label within the sections, tabs and columns around it, so keep labels stable or pass an id. Repeated labels are told apart by their order.

angle(label, radians, options?): number

An angle in radians, shown and typed in degrees.

string

number

NumberOptions

number


button(label, options?): boolean

Returns true in the draw that reports the click. That draw may edit the model, so call Model.operation right there.

string

WidgetOptions & object

boolean


canvas(label, height, draw, options?): CanvasEvent | null

A canvas height pixels high that fills the window’s width. draw adds its shapes and receives what the user did with the mouse on it, or null, so it can show the effect right away; canvas returns the same event. The draw that reports an event may edit the model, like a clicked button’s.

ui.canvas("Nodes", 200, (canvas, event) => {
if (event?.type === "drag" && event.item === "node") {
node.x += event.dx;
node.y += event.dy;
}
canvas.rect(node.x, node.y, 80, 40, { id: "node", fill: { r: 0.2, g: 0.3, b: 0.5, a: 1 } });
});

string

number

(canvas, event) => void

WidgetOptions

CanvasEvent | null


checkbox(label, value, options?): boolean

string

boolean

WidgetOptions

boolean


close(): void

Closes this panel or dialog.

void


color(label, value, options?): Color

string

Color

WidgetOptions & object

Color


columns(draws, options?): void

Equal-width columns, one per function.

readonly () => void[]

WidgetOptions

void


disabled(when, draw): void

Grays out the widgets draw adds while when is true.

boolean

() => void

void


dropdown<T>(label, value, choices, options?): T

Chooses one of many options from a list; returns the chosen one.

T extends string

string

T

readonly T[]

WidgetOptions

T


form<T>(values, schema): T

Draws one field per entry of schema, identified by its key, and returns a copy of values with the user’s changes.

state = ui.form(state, {
width: { type: "length", label: "Width", min: 0.1 },
shape: { type: "dropdown", label: "Shape", choices: ["Straight", "L-shaped"] },
});

T extends Record<string, unknown>

T

Readonly<Record<string, FormField>>

T


heading(text, options?): void

unknown

WidgetOptions

void


image(image, options?): void

Shows an image the plugin loaded, at its own size in pixels, or at a width or height that keeps its proportions when only one is given.

PluginImage

WidgetOptions & object

void


integer(label, value, options?): number

string

number

RangeOptions

number


length(label, meters, options?): number

A length in meters, shown in the model’s units. It accepts everything the measurements box accepts, such as 1.2m, 18cm, 7" or 5' 3 1/2".

string

number

RangeOptions

number


material(label, value, options?): Material | null

Chooses one of the model’s materials, shown with their colors, or null for the default material. Assign the result inside Model.operation in the draw that reports it.

string

Material | null

WidgetOptions

Material | null


number(label, value, options?): number

A decimal number; typed text outside the range is refused.

string

number

NumberOptions

number


progress(fraction, options?): void

number

WidgetOptions & object

void


radio<T>(label, value, choices, options?): T

Chooses one of a few options shown side by side; returns the chosen one.

T extends string

string

T

readonly T[]

WidgetOptions

T


readOnly(label, value, options?): void

A labeled value that can’t be edited.

string

unknown

WidgetOptions

void


row(draw, options?): void

Places the widgets draw adds side by side, such as a row of buttons.

() => void

WidgetOptions

void


section(title, draw, options?): void

A heading that folds the widgets draw adds; open by default.

string

() => void

WidgetOptions & object

void


separator(title?, options?): void

A horizontal rule, with an optional title set into it.

string

WidgetOptions

void


slider(label, value, options?): number

Drag to change; Ctrl+click to type a value.

string

number

SliderOptions

number


spacing(): void

Vertical space between groups of widgets.

void


table(label, columns, rows, selection, options?): string | null

A table whose columns sort when the user clicks their header; cells that start with a number, such as "1.2 m", sort by it. Pass the selected row’s id, or null, and get the user’s new choice back. Pass an array of ids instead to let Ctrl+click and Shift+click select several rows; the result is then an array too.

string

readonly TableColumn[]

readonly TableRow[]

string | null

TableOptions

string | null

table(label, columns, rows, selection, options?): string[]

string

readonly TableColumn[]

readonly TableRow[]

readonly string[]

TableOptions

string[]


tabs(pages, options?): void

Tabs, from each tab’s title to the function that draws it.

Readonly<Record<string, () => void>>

WidgetOptions

void


text(text, options?): void

Wrapped text, optionally in a tone.

unknown

WidgetOptions & object

void


textBox(label, value, options?): string

Multi-line text that wraps; 4 visible lines by default.

string

string

WidgetOptions & object

string


textField(label, value, options?): string

string

string

WidgetOptions & object

string


toggle(label, value, options?): boolean

An on/off switch, for settings that apply right away.

string

boolean

WidgetOptions

boolean


tree(label, items, selected, options?): string | null

A tree of selectable items, such as an outliner. Returns the selected item’s id, or the user’s new choice; null when nothing is selected. Arrows fold and unfold items.

string

readonly TreeItem[]

string | null

WidgetOptions

string | null