I want to be able to change the background color of a property ui.

At the moment it does:

  • Green = has an Fcurve
  • Yellow = has a keyframe
  • Purple = has a Driver

I want to to be able to change the color of the background depending my own conditions. IE I don't want to change the color theme, I want to add a new color and define its condition.

For Example: If a property is above 500 it changes to red!

Is this possible?


The colors are controlled by C code, you can't set it to arbitrary colors with python.

However, you can change the background to alert color (=red) by setting the alert property on the layout block:

Panel - layout alert state

import bpy

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout

        obj = context.object
        if obj is None: return

        col = layout.column()
        col.alert = True
        col.label("Alert state NOT supported:")

        box = col.box()
        box.label("Labels", icon="X")
        box.menu("VIEW3D_MT_object", text="Menus")
        box.prop(obj, "layers", text="Not all properties")

        box = col.box()
        box.operator("mesh.primitive_cube_add", text="Operators (Buttons)")
        box.prop(obj, "name", text="Many properties")
        box.prop(obj, "location", index=1, text="Vector props: only single")
        box.label("also with emboss=False, but...")
        box.prop(obj, "name", text="read-only?!", emboss=False)
        box.label("template_list() sort of (needs materials):")
        box.template_list("UI_UL_list", "foobar", obj.data, "materials", obj, "active_material_index")

def register():

def unregister():

if __name__ == "__main__":

Run the above code in Text Editor and check out the Object tab.

  • $\begingroup$ Thank you!. I could use the alert to color my property but how can I change the color from red? $\endgroup$ – MCHammond Apr 24 '14 at 20:38
  • $\begingroup$ Unlike the other colors for animated and driven properties, the alert color is hardcoded to red. $\endgroup$ – CoDEmanX Apr 24 '14 at 21:25
  • $\begingroup$ thank you man .... which c file control colors ? $\endgroup$ – Arash Hatami May 28 '16 at 13:25

Is it possible to set a node's socket label background color in 2.79 .. or perhaps in 2.8? See the illustration below for the desired effect. Sometimes I would like to visually group together sockets to a node which belong to a set of inputs and thus be able to differentiate between the multiple sets.

The illustration picture shows 3 different scenarios how the visual grouping could be done.. from left (least desirable) to right (most desirable). First, each socket gets background color (visually separated from the next). The second has the two sockets be grouped, the backgrounds touch.. or are just one larger rectangle). the third, the background stretches from side to side of the node, essentially being able to create the effect of alternating row colors.

Socket label background color


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.