UICssDocument & CSS Support Reference
UICssDocument wraps an RmlUi 6.4 HTML/CSS document and renders it onto Blender's GPU. Inside a blendcss.Panel, access the mounted document via self.doc.
DOM & Event Methods
| Method | Signature | Description |
|---|---|---|
doc[elem_id] / doc.el | el(elem_id: str) -> ElementHandle | Returns a live ElementHandle proxy for elem_id. |
doc.get_element_by_id | get_element_by_id(elem_id: str) | Returns the raw RmlUi element wrapper, or None. |
doc.on | on(elem_id: str, event_type: str, callback) -> bool | Attaches an event listener (supports 0-arg or 1-arg callbacks). |
doc.set_text / doc.get_text | set_text(elem_id, text) / get_text(elem_id, default="") | Sets or gets escaped plain text (dirty-checked). |
doc.set_html / doc.get_html | set_html(elem_id, html) / get_html(elem_id, default="") | Sets or gets inner HTML/RML markup with px → dp preprocessing. |
doc.set_style | set_style(elem_id, prop=None, value=None, **styles) | Sets inline CSS properties (accepts (prop, val), a dict, or kwargs). |
doc.set_attr / doc.get_attr | set_attr(elem_id, name, value) / get_attr(elem_id, name, default="") | Sets or reads an HTML attribute. |
doc.set_class | set_class(elem_id, class_name, activate: bool) | Activates or removes a CSS class (dirty-checked). |
doc.add_class / doc.remove_class | add_class(elem_id, name) / remove_class(elem_id, name) | Adds or removes a CSS class. |
doc.toggle_class / doc.is_class_set | toggle_class(elem_id, name) -> bool / is_class_set(elem_id, name) -> bool | Toggles or queries a CSS class. |
doc.set_visible / doc.show / doc.hide | set_visible(elem_id, visible, display=None) | Shows or hides an element while remembering its previous display mode. |
Document Lifecycle, Theme & Images
| Method | Signature | Description |
|---|---|---|
doc.load_content | load_content(rml="", rml_file=None, css="", css_file=None, base_dir=None, html=None, html_file=None) | Loads or reloads HTML/RML and CSS content. |
doc.sync_bindings | sync_bindings() | Synchronizes all registered numeric, toggle, choice, text, and operator bindings. |
doc.unbind_all | unbind_all() | Clears all registered bindings on the document. |
doc.sync_theme | sync_theme(force: bool = False) | Syncs Blender's live --bl-* CSS custom properties and Dark/Light rules. |
doc.set_theme_override | set_theme_override(overrides: dict = None) | Overrides specific --bl-* variables (pass None to clear). |
doc.register_image | register_image(name, source, width=None, height=None, flip_y=None, premultiply=True) -> str | Registers or updates an in-memory image (bpy.types.Image, NumPy array, or RGBA bytes) and returns "blendcss://...". |
doc.unregister_image | unregister_image(name: str) | Releases a registered in-memory GPU image. |
doc.tag_update | tag_update() | Marks the document for layout recomputation and redraw. |
doc.destroy | destroy() | Releases RmlUi context, document, and offscreen GPU buffer. |
Supported CSS Features
Layout & Box Model
- Flexbox:
display: flex,flex-direction,flex-wrap,justify-content,align-items,align-self,gap,flex,flex-grow,flex-shrink - Box Model:
width,height,min-width,max-width,min-height,max-height,margin,padding,box-sizing: border-box,overflow: hidden - Positioning:
position: relative | absolute,top,right,bottom,left,z-index
Visuals & GPU Shaders
- Colors & Variables: Hex (
#rgb,#rrggbb,#rrggbbaa),rgb(),rgba(r, g, b, 0..255), CSS custom properties (var(--bl-*)) - Borders & Corners:
border: 1px #color,border-top/right/bottom/left,border-radius(with roundedoverflow: hiddenclipping) - Gradients:
linear-gradient(...),radial-gradient(...),conic-gradient(...), andrepeating-*variants - Effects:
box-shadow,backdrop-filter: blur(...),opacity,text-shadow
Typography & Icons
- Fonts:
font-family,font-size,font-weight(100–900or keywords likemedium,semibold,bold),font-style,letter-spacing,line-height,text-align,text-overflow: ellipsis,@font-face - SVGs:
image-colorfor tinting normalized inline<svg>icons
Supported CSS Cursors
CSS cursor value | Blender cursor |
|---|---|
auto, default | Default |
pointer, hand | HAND_POINT |
grab / grabbing | HAND / HAND_CLOSED |
text, vertical-text | TEXT |
ew-resize, col-resize, e-resize, w-resize | SCROLL_X |
ns-resize, row-resize, n-resize, s-resize | SCROLL_Y |
move, all-scroll, nesw-resize, nwse-resize | SCROLL_XY |
crosshair / cell | CROSSHAIR / CROSS |
wait, progress | WAIT |
not-allowed, no-drop | STOP |
copy | COPY |
zoom-in / zoom-out | ZOOM_IN / ZOOM_OUT |
none | NONE |