UIBuilder & Default Classes Reference
UIBuilder is passed as ui into Panel.draw(self, ui, context) and Panel.build(self, ui). Every container method supports both with context blocks and Blender-style chaining (row = card.row(); row.label(...)).
Container Methods
All container and element methods accept common keyword arguments: id, cls, style (dict or CSS string), on_click, on (dict of {event: callback}), visible=True, and arbitrary HTML **attrs.
| Method | Signature | Default Class | Description |
|---|---|---|---|
ui.row | row(*, gap=None, align=None, justify=None, ...) | .bl-row | Horizontal Flexbox container. |
ui.col | col(*, gap=None, align=None, justify=None, ...) | .bl-col | Vertical Flexbox container. |
ui.card | card(*, title=None, subtitle=None, ...) | .bl-card | Blender-themed card with optional header title and subtitle. |
ui.section | section(title: str, ...) | .bl-section | Titled vertical group. |
ui.div | div(text=None, ...) | — | Generic <div> container. |
ui.span | span(text=None, ...) | — | Inline <span> element. |
ui.el | el(tag: str, text=None, ...) | — | Arbitrary HTML element (e.g. ui.el("footer", cls="bar")). |
Display & Content Widgets
| Method | Signature | Description |
|---|---|---|
ui.label | label(content="", *, bind=None, target=None, prop=None, default="", format_fn=None, as_html=False, tag="span", ...) | Static or reactive text/HTML label. |
ui.heading | heading(content="", *, level=2, ...) | Section heading (.bl-heading.bl-h1, .bl-h2, .bl-h3). |
ui.badge | badge(label="", *, variant="", bind=None, target=None, prop=None, default="", format_fn=None, ...) | Compact pill badge. Variants: "", "accent", "success", "warning", "error". |
ui.divider | divider(...) | Horizontal 1px rule (.bl-divider). |
ui.icon | icon(name, *, size=16, color=None, stroke_width=None, tintable=True, ...) | Inline vector <svg> icon via blendcss.svg_icon. |
ui.img | img(src, ...) | Image element supporting local file paths and blendcss:// live GPU textures. |
ui.progress | progress(value=0.0, *, max_val=1.0, fill_cls="", ...) | Progress bar returning a ProgressNode with a live .value property. |
ui.raw | raw(html_str: str) | Inserts raw HTML/RML markup verbatim inside the current container. |
Interactive Controls
ui.button(...)
ui.button(
label="",
*,
icon=None,
icon_size=14,
variant="", # "", "primary", "ghost", "danger"
on_click=None,
on=None,
operator=None, # Optional: bind a Blender operator directly
op_props=None,
exec_ctx="INVOKE_DEFAULT",
undo=True,
disabled_class="is-disabled",
sync_poll=True,
context_override="AUTO",
on_done=None,
on_error=None,
id=None,
cls="",
style=None,
visible=True,
**attrs,
)ui.operator(...)
Returns an OperatorNode with .enabled (bool) and .invoke(**extra_props). Any extra **op_kwargs are passed as Blender operator properties.
ui.operator(
operator, # "mod.op", "MOD_OT_op", or bpy.ops.mod.op
label=None, # Defaults to Blender's RNA operator name
*,
icon=None,
icon_size=14,
variant="", # "", "primary", "ghost", "danger"
props=None, # Static dict or callable returning dict
exec_ctx="INVOKE_DEFAULT",
undo=True,
event="click",
disabled_class="is-disabled",
sync_poll=True,
context_override="AUTO",
on_done=None,
on_error=None,
id=None,
cls="",
style=None,
visible=True,
attrs=None,
**op_kwargs,
)ui.number(...)
Returns a NumberNode with .value, .binding, .box, and .value_el. Supports horizontal drag-scrubbing (Shift fine, Ctrl snap) and click-to-type AST math expressions.
ui.number(
label=None,
*,
value=0.0,
bind=None, # (target, "prop") or (target, "prop", index)
target=None,
prop=None,
index=None,
step=0.01,
min_val=None,
max_val=None,
precision=2,
unit="",
is_rotation=False, # Displays degrees, stores radians
on_change=None,
formatter=None,
id=None,
cls="",
box_cls="",
val_cls="",
style=None,
visible=True,
**attrs,
)ui.toggle(...)
Returns a ToggleNode with .value, .binding, and .switch.
ui.toggle(
label=None,
*,
subtitle=None,
value=False,
bind=None,
target=None,
prop=None,
active_class="is-on",
inactive_class=None,
on_change=None,
id=None,
cls="",
switch_cls="",
style=None,
visible=True,
**attrs,
)ui.tabs(...) and ui.choice(...)
Both return a ChoiceNode with .value and .binding. items accepts a {value: label} dict or a list of (value, label) tuples.
ui.tabs(items, *, value=None, bind=None, target=None, prop=None, active_class="is-active", on_change=None, id=None, cls="", item_cls="", style=None, visible=True, **attrs)
ui.choice(items, *, value=None, bind=None, target=None, prop=None, active_class="is-active", on_change=None, id=None, cls="", item_cls="", style=None, visible=True, **attrs)Live Node Handles (UINode & ElementHandle)
Every UIBuilder widget returns a UINode (and doc["id"] / doc.el("id") returns an ElementHandle) with the following live API:
| Member | Type / Signature | Description |
|---|---|---|
.text | str (get/set) | Escaped plain text inside the element. |
.html | str (get/set) | Inner HTML/RML markup. |
.visible | bool (get/set) | Shows or hides the element while preserving its prior display mode. |
.show(display=None) / .hide() | method | Explicitly shows or hides the element. |
.style(prop=None, value=None, **styles) | method | Sets inline CSS properties (underscores convert to hyphens, e.g. background_color="#333"). |
.attr(name, value=...) | method | Gets or sets an HTML attribute. |
.add_class(*names) / .remove_class(*names) | method | Adds or removes CSS classes. |
.set_class(name, activate) / .toggle_class(name) / .has_class(name) | method | Toggles or queries a CSS class. |
.on(event_type, callback) | method | Attaches an event listener. |
.bind_operator(operator, ...) | method | Binds a Blender operator to this node. |
.width, .height, .left, .top | float (read-only) | Computed layout geometry in pixels. |
Default CSS Classes (DEFAULT_UI_CSS)
Loaded automatically unless default_styles = False:
- Layout:
.bl-row,.bl-col,.bl-card,.bl-card-header,.bl-card-title,.bl-card-subtitle,.bl-section,.bl-section-title,.bl-divider - Typography:
.bl-heading,.bl-h1,.bl-h2,.bl-h3 - Buttons:
.bl-btn,.bl-btn-flex,.bl-btn-primary,.bl-btn-ghost,.bl-btn-danger,.bl-btn-icon - Badges & Progress:
.bl-badge,.bl-badge-accent,.bl-badge-success,.bl-badge-warning,.bl-badge-error,.bl-progress,.bl-progress-fill - Inputs:
.bl-num-row,.bl-num-label,.bl-num-box,.bl-num-val,.bl-toggle-row,.bl-toggle-info,.bl-toggle-label,.bl-toggle-sub,.bl-switch,.bl-switch.is-on,.bl-switch-thumb - Tabs & Choices:
.bl-tabs,.bl-tab,.bl-tab.is-active,.bl-choice-group,.bl-choice-item,.bl-choice-item.is-active