How to enable or disable panels with the click of a button
It's a panels poll method
The panels are defined and sitting there polling away, waiting to &quot;show&quot;.
The poll classmethod of a panel returns true only when the required context (or otherwise related) conditions are met
Poll method for custom panel
Hide Panel With Python (&quot;A Duality Duplicate&quot;)
In example displayed in question :
(Speculating haven't checked (...lately), Turn on Developer Extras in settings, so can right click on 99% of UI, view source and see how its done... a common practice is to)
Have one master materials panel, that always polls.  In this case the material slots, no panel header, has the option to add a material.
All the others seen are , subpanels ie Panels with their parent set to the master panel, or others in the space, that have poll requirements met.
In the properties space, there is a sort of &quot;polling&quot; option available by setting bl_context of the panel class to match that of the properties space context, matching the 'OBJECT', 'SCENE', 'RENDER' tabs.
Creating new tabs in properties panel
How do I add a panel to Object Properties?
These subpanels only poll when there is a context.material (In properties space there is a material context member, most likely context.material == context.object.active_material
When all the panels require the same poll it is common to see a mixin base class
class SomePanelBase:
    bl_context = 'MATERIAL'
    @classmethod
    def poll(cls, context):
        return context.material is not None

And for any defined panel
class MaterialFooPanel(SomePanelBase, bpy.types.Panel):
    ...

making any such defined panels only display if there is an active material.