Is it possible to make collapsible panel like it is for object modifiers? I need something similar for my plugin. After choose menu item I want to create new panel with collapsible box, where can I change parameters for objects.


I tried before to make panel with bpy.types.UILayout.template_list but it was too hard to build from scratch for me. Documentation isn't very friendly, it's hard to know what can I use for these arguments (active_dataptr, active_propname).

Next months I'm working on my plugin, before that I need to make good UI for it.

  • $\begingroup$ Have you tried to check the Python code for the modifiers' UI? $\endgroup$ Nov 22, 2014 at 18:37
  • $\begingroup$ Yes I tried but it's more complex and associated with different global variables. Here is a part of modifier UI $\endgroup$
    – Reborn
    Nov 22, 2014 at 19:09
  • $\begingroup$ possible duplicate of How to make compare with Menus $\endgroup$ Nov 23, 2014 at 14:37

1 Answer 1


It's basically a camouflaged checkbox (boolean property) with changing icon:

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

        box = layout.box()

        row = box.row()
        row.prop(obj, "expanded",
            icon="TRIA_DOWN" if obj.expanded else "TRIA_RIGHT",
            icon_only=True, emboss=False
        row.label(text="Active object is: " + obj.name)

        if obj.expanded:
            row = box.row()
            row.prop(obj, "name")

            row = box.row()
            row.label(text="Hello world!", icon='WORLD_DATA')

            row = box.row()

def register():
    bpy.types.Object.expanded = bpy.props.BoolProperty(default=True)

def unregister():
    del bpy.types.Object.expanded

if __name__ == "__main__":
  • 6
    $\begingroup$ For anyone using Blender 2.8+ passing around : now you can also create a sub-panel (create another Panel and set its bl_parent_id property to the bl_idname of the first one). Make sure you define draw method in the parent panel (even if empty) and it will render the child panel in a foldable way. $\endgroup$ Jan 2, 2021 at 7:24
  • $\begingroup$ for anyone running into same issue with obj.expanded is specific to that object. if you want the panel expanded "globally" for every object you can use bpy.types.Scene.expanded when registering then use context.scene.expanded in the draw function $\endgroup$ Mar 21 at 2:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .