Add Icons, Fonts & Live Images
This guide explains how to use built-in and custom vector SVG icons, load custom fonts, and display live bpy.types.Image or NumPy textures directly on the GPU.
Use built-in SVG icons
blendcss ships 16 Lucide-style vector icons out of the box (cube, sun, camera, sparkles, layers, sliders, eye, star, star-outline, dots, zap, palette, check, refresh, folder, image).
In UIBuilder:
ui.icon("sparkles", size=18, color="var(--bl-accent)")
ui.button("Duplicate", icon="layers", icon_size=14, variant="primary")
ui.operator("view3d.view_all", "Frame", icon="eye")In raw HTML templates:
markup = blendcss.svg_icon("sparkles", size=18, color="var(--bl-accent)")Load custom SVG icon packs
Register a single .svg string, a single file, or an entire directory (such as Lucide, Tabler, or Heroicons) once when your addon registers:
import os
from . import blendcss
ICONS_DIR = os.path.join(os.path.dirname(__file__), "icons")
def register():
# Indexes all .svg files recursively: icons/arrow-right.svg -> "lucide/arrow-right"
blendcss.register_svg_dir(ICONS_DIR, prefix="lucide")
# Or register a single inline SVG
blendcss.register_svg_icon("my_dot", '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/></svg>')
blendcss.register(MyPanel)Then use the registered name anywhere an icon is accepted:
ui.icon("lucide/arrow-right", size=16)How SVG tinting works in RmlUi
blendcss automatically normalizes SVGs so currentColor renders in white and can be tinted cleanly with the CSS image-color property (or the color= argument on ui.icon()). Pass tintable=False for multi-color SVGs that should preserve their original fills.
Load custom fonts
blendcss automatically loads Blender's bundled Inter (sans-serif, weights 100–900), DejaVu Sans Mono (monospace), and symbol fallback fonts.
To add your own .woff2, .ttf, .otf, or .ttc fonts:
Option 1: Load via Python
import os
from . import blendcss
FONTS_DIR = os.path.join(os.path.dirname(__file__), "fonts")
# Load a single font file with an explicit family name and weight
blendcss.load_font(
os.path.join(FONTS_DIR, "SpaceGrotesk-Bold.woff2"),
family="Space Grotesk",
weight="bold",
)
# Or load every font file in a directory
blendcss.load_font_dir(FONTS_DIR)Option 2: Declare @font-face in CSS
@font-face {
font-family: "Space Grotesk";
src: url("fonts/SpaceGrotesk-Regular.woff2");
font-weight: 400;
}
.heading {
font-family: "Space Grotesk", sans-serif;
font-weight: 400;
}Display live GPU images (blendcss://)
Register in-memory images directly to the GPU without writing temporary files to disk. Supported sources:
bpy.types.Image(flipped vertically automatically to match UI coordinates)- NumPy array with shape
(H, W, 3)or(H, W, 4)(uint8orfloat32in[0.0, 1.0]) - Raw RGBA8
bytes/bytearray/memoryview(requireswidth=andheight=)
Register and display a NumPy array or Blender image
import bpy
import numpy as np
# Inside your Panel (e.g., on_mount or a button callback):
arr = np.zeros((64, 160, 4), dtype=np.uint8)
arr[:, :, 0] = 240 # Red channel
arr[:, :, 3] = 255 # Alpha channel
self.doc.register_image("my_preview", arr)
# Or upload a Blender image directly:
bl_img = bpy.data.images.get("Render Result")
if bl_img:
self.doc.register_image("render_thumb", bl_img)Reference the registered image with the blendcss:// scheme in ui.img(...) or <img src="..."/>:
ui.img("blendcss://my_preview", cls="preview-img")To update the texture live, call self.doc.register_image("my_preview", new_arr) again with the same name. When you no longer need the texture, call self.doc.unregister_image("my_preview") to free GPU memory.
For full signatures and options, see the Theme & Assets Reference.