I’m trying to develop v2 of awesome-panel.org and I would like my main item to
2. expand to a max width of 1140px.
I’ve tried all that I can think of
- css in the template (Does not work well with bokeh layout engine)
- different kinds of Panel layouts and spacers
but I cannot get it working.
I hope someone can help.
I will provide more context in by posting some examples of what does not work below.
This is an example where my main object is a Column.
I set the
sizing_mode="stretch_height" and place it inside a row with a Spacer
on both side pn.Row(pn.Spacer(), main, pn.Spacer())`
It works when the window size is larger than 1140px but not for smaller screens as the main column keeps it width of 1140px.
I managed to get something working. It took some time and I needed a trick with a
Spacer to get it working. So I want to share it here.
import panel as pn
spacer = pn.Spacer(height=10, background="blue", margin=0)
main_content = pn.Column(
"Example 3 "*100,
align="center" # WHY I SHOULD set align="center" here and not on main_area confused me
main_area = pn.Column(
spacer, # TRICK: WONT WORK WITHOUT. YOU CAN SET HEIGHT TO 0 TO NOT TAKE UP HEIGHT
And here is how to original looks with the solution.
Thanks for sharing! I’m wondering if panel can have a built-in version of this, like
pn.CenteredColumn or something.
Align always confused me as well.