# Is there a way to set width of the panels?

**URL:** <https://forum.xwiki.org/t/is-there-a-way-to-set-width-of-the-panels/9062>\
**Category:** Help / Discuss\
**Created:** [August 4, 2021, 8:44pm UTC](https://forum.xwiki.org/t/is-there-a-way-to-set-width-of-the-panels/9062 "2021-08-04T20:44:28Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![NorSch](https://forum.xwiki.org/user_avatar/forum.xwiki.org/norsch/32/3116_2.png) [@NorSch](https://forum.xwiki.org/u/NorSch)\
**Post date:** [August 8, 2022, 5:51pm UTC](https://forum.xwiki.org/t/is-there-a-way-to-set-width-of-the-panels/9062/4 "2022-08-08T17:51:23Z")

</div>

The following JavaScriptExtension uses the CSS resize feature to make the width of a panel dynamic.

```auto
 var panelObserver = new ResizeObserver(function (entries) {
      entries.forEach(function (entry) {
          var leftPanelsWidth = function () {
              var leftPanels = document.getElementById("leftPanels");
              if (leftPanels == null) {
                  return 0
              } else {
                  return leftPanels.getWidth()
              }
          };
          var rightPanelsWidth = function () {
              var rightPanels = document.getElementById("rightPanels");
              if (rightPanels == null) {
                  return 0
              } else {
                  return rightPanels.getWidth()
              }
          };
          if (entry.target.id == "leftPanels" || entry.target.id == "rightPanels") {
              var contentColumn = document.getElementById("contentcolumn").children[0];
              var leftPanels = document.getElementById("leftPanels");
              var containerWidth = document.getElementById("contentcontainerinner").getWidth();
              var paddingCorrection = 60;
              contentColumn.style["left"] = 100 * leftPanelsWidth() / containerWidth + "%";
              contentColumn.style["width"] = 100 * (containerWidth - rightPanelsWidth() - leftPanelsWidth() - paddingCorrection) / containerWidth + "%";
              if (leftPanels != null) {
                  leftPanels.style["right"] = contentColumn.style["width"]
              };
          };
      });
  });

  if (document.getElementById("leftPanels") != null) {
      document.getElementById("leftPanels").style["resize"] = "horizontal";
      document.getElementById("leftPanels").style["overflow"] = "hidden";
      panelObserver.observe(document.getElementById("leftPanels"));
  };

  if (document.getElementById("rightPanels") != null) {
      document.getElementById("rightPanels").style["resize"] = "horizontal";
      document.getElementById("rightPanels").style["overflow"] = "hidden";
      panelObserver.observe(document.getElementById("rightPanels"));
  };
 

```

It is a bit “dirty”, as it uses the HTML ids of the page layout, but it works.

(Used with flamingo skin).

---

_[View the full topic](https://forum.xwiki.org/t/is-there-a-way-to-set-width-of-the-panels/9062)._
