I use the MaterialTemplate on a dashboard and use the sidebar for some plot controls. Generally very satisfied with it but it does not seem like the width of the sidebar scales with the width of the controls, see the attached picture. The widgets are appended separately to the sidebar. Does anyone know if this is expected and if there is a setting to control the width, of any other workaround?
It can be improved based on feature requests on github.
Personally I prefer a fixed width and responsive widgets. That is my experience from lots of work with Panel templates. But I would like to be able to specify the fixed width.
If you are using CSS with your template already, then paste the below to your CSS variable. As you can see, I’ve changed the sidebar (mdc-drawer) component’s width to 500px. Easy peasy.
If you are not using any CSS yet in your app, then follow the steps below.
Declare a variable right after the imports for example css = ‘’’ … ‘’’
Replace … with the snippets above.
Then add raw_css=[css] into your pn.extension()
…
Profit
!!! Please, note the above works with the Material template only. If you are using any of the other templates, then what you do is. Go to your venv/site-packages/panel/template dir, then open the relevant template folder, then open the template’s css file. (example: react folder → react.css). Then you need to look for the right CSS component in there. as @Marc mentioned above the default value is 300px. This is the easiest way to identify the right component, just look for 300px. !!!
Thanks a lot, @danmaty and @Marc, for engaging with me on this issue. I really appreciate it. I tried the CSS modifications and it worked fine for the sidebar, but it seems like the distance from the left side of the window to the content on the right is controlled by another fixed-parameter so it ended up covering part of the content on the right side. I did not want to modify the panel package if I could avoid it so what I ended up with was actually limiting the width of the widgets, an option I did not think of in the beginning, and at least this ensures that they fit on the sidebar…
Without actually trying it, I’m guessing it doesn’t work because you are using Panel 0.11.x.
A number of changes have been made in 0.11.0 that were impacting certain CSS elements’ behaviour in certain templates. I still use a previous version of Panel with one of my Heroku apps due to this.
I’d suggest to try it with 0.10.x first baring in mind some of the panes/widgets/etc were not available back then.