Skip to content

Style Panels & Sync Themes ​

This guide shows how to style blendcss panels with CSS, use live Blender theme variables, handle Dark/Light mode differences, and opt out of default styles when you want full control.

Add inline or external CSS ​

Attach CSS to a blendcss.Panel with css (inline string) or css_file (external file resolved relative to your panel's Python module):

python
class StyledPanel(blendcss.Panel):
    addon_id = "my_addon"
    category = "My Addon"
    label = "Styled Panel"
    css_file = "styles/panel.css"  # Relative to this .py file

To hot-reload your external .css file while iterating in Blender, call self.reload() (for example, from a small refresh button in your panel footer).

Use live Blender theme variables (--bl-*) ​

By default (sync_theme = True), blendcss reads Blender's active theme (across both Blender 4.x and 5.x) and injects --bl-* CSS custom properties into your document. When the user switches themes in Blender Preferences, your panel updates live.

css
.tool-card {
    padding: 12px;
    border-radius: var(--bl-radius-panel);
    background: linear-gradient(180deg, var(--bl-bg-card-top), var(--bl-bg-card-bottom));
    border: 1px var(--bl-border-subtle);
    color: var(--bl-text);
}

.tool-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--bl-text-title);
}

.tool-action {
    border-radius: var(--bl-radius);
    background-color: var(--bl-accent);
    color: var(--bl-accent-text);
}

.tool-action:hover {
    background-color: var(--bl-accent-hover);
}

Commonly used variables:

  • Surfaces: --bl-bg, --bl-bg-card, --bl-bg-sub, --bl-bg-inset, --bl-bg-button, --bl-bg-button-hover
  • Text: --bl-text, --bl-text-title, --bl-text-widget, --bl-text-muted
  • Accents & Status: --bl-accent, --bl-accent-hover, --bl-accent-text, --bl-success, --bl-warning, --bl-error, --bl-axis-x, --bl-axis-y, --bl-axis-z
  • Geometry: --bl-radius, --bl-radius-panel, --bl-border, --bl-border-subtle

For the complete list of all 35 variables, see Theme & Assets Reference.

Target Dark and Light themes specifically ​

blendcss exposes two ways to write theme-specific CSS rules:

Option 1: @media (theme: ...) queries ​

css
@media (theme: dark) {
    .hero-banner {
        background-color: #1e222b;
    }
}

@media (theme: light) {
    .hero-banner {
        background-color: #e8ecf4;
    }
}

Option 2: Root classes .bl-theme-dark and .bl-theme-light ​

css
.bl-theme-dark .subtle-badge {
    background-color: rgba(255, 255, 255, 18);
}

.bl-theme-light .subtle-badge {
    background-color: rgba(0, 0, 0, 15);
}

Override specific theme tokens ​

Override individual --bl-* variables per panel using theme_overrides:

python
class BrandedPanel(blendcss.Panel):
    addon_id = "my_addon"
    category = "My Addon"
    label = "Branded Tool"
    theme_overrides = {
        "--bl-accent": "#e07a24",
        "--bl-accent-hover": "#f08a34",
        "--bl-radius": "8dp",
    }

You can also change overrides dynamically at runtime with self.doc.set_theme_override({"--bl-accent": "#3aa76d"}) or pass None to restore Blender's live theme.

Start from a blank stylesheet ​

UIBuilder loads DEFAULT_UI_CSS automatically so .bl-card, .bl-btn, .bl-num-box, and .bl-switch look native out of the box.

To remove all default widget styles and write 100% custom CSS:

python
class CustomSlatePanel(blendcss.Panel):
    addon_id = "my_addon"
    category = "My Addon"
    label = "Custom Slate"
    default_styles = False
    css_file = "custom.css"

Style disabled operators and interactive states ​

  • Disabled operators: Style .is-disabled (the default class added when op.poll() returns False):
css
.tool-action.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
  • Cursors: Standard CSS cursors (pointer, ew-resize, grab, text, not-allowed, crosshair) map automatically to Blender's native window cursors.
  • Visual effects: blendcss supports linear-gradient(...), radial-gradient(...), conic-gradient(...), box-shadow, backdrop-filter: blur(...), and border-radius overflow clipping. See CSS & GPU Rendering for RmlUi CSS details.

Released under the GNU GPL v3.0 License.