On dbc/dcc components and inheritance

Hello,

I’m fairly new to Dahs Plotly but i’ve fallen into an issue that i’m not sure I can’t seem to answer by myself.

The issue is the following, when should any of my component extend an already existing dbc dcc class.
For instance, say I have the following AIO component

class MyComponent(html.Div):
    def __init__(self, ...):
        super().__init__(
            dbc.Component(...) # dcc.Component(..)
        )

Should I always turn it into this based on its root component ?

class MyComponent(dbc.Component):
    def __init__(self, ...):
        super().__init__(
            (..)
        )

hi @Zakary_Bouchema ,
can you please share more about your use case?

Hello, currently I have a static version of my webapp, with a collapsible sidebar using an offcanvas, some tabs, and some modals. I’ve built every component by having my component (AIO or not) inherit from html.Div. This sometimes led to some extreme indentation, which is okay-ish.

But I’ve realized that, for instance, instead of having my sidebar inherit from html.Div, I could directly make it inherit from dbc.Col. However, doing this, I realized that when I wanted to quickly see what the layout would look like, I would first need to look at the inheritance of my component and then the children in the __init__, whereas when I used html.Div, I would only ever need to look at the latter.

So far, I’ve only ever used Dash for layout composition (and a global store), and I’ve never needed to “make my own Col or Offcanvas”.

So I was wondering what the best practice is when developing in Dash. Should every component that’s related to layout composition inherit from html.Div, and should I only inherit from other classes when I need to build my own Col or Modal?