A workaround for `width_policy="fit"` + `sizing_mode="stretch_width"`

Since I don’t think width_policy is functional (I could be wrong), if you have pn.extension(sizing_mode="stretch_width") but…

  1. don’t want a component to stretch
  2. don’t want to set a fixed width + height
  3. don’t want to encounter these warnings when setting sizing_mode="fixed": (FIXED_SIZING_MODE): 'fixed' sizing mode requires width and height to be set: HTML(id='p1194', ...)

Use stylesheets or styles:
styles=dict(width="fit-content")

Before:

After:

2 Likes