I’m using bootstrap CSS to create my layout. I imagine my approach is wrong as it takes lots of code to create nested div classes. Please let me know if their is a more appropriate way to build my layout. The code is below:
This example isn’t too bad, but it will quickly become a lot if I want to add more more bootstrap features to each column (such as cards or a jumbotron).
Thanks for writing in. Bootstrap and other CSS should work exactly the same in Dash as it would in any HTML (<div class='col-sm'></div> is the same as html.Div([], className='col-sm').
You’re on the right track, and I’ll leave it to other community members to offer more general advice on how they’ve dealt with bootstrap features.
As I mention in this reply, my strategy for managing Bootstrap classes is similar to @mikesmith1611 but more general. I use Row and Col functions that would allow me to write your code like this:
(Note that you can pass the children keyword argument in without a name if it’s the first argument)
You could define Col and Row as simple functions that just wrap html.Divs or you could also make them a bit more intelligent in how they pass on kwargs etc into the inner components. I do a bit of that in this project. You can find the functions in components.py which make use of a decorator to help pass through arguments.