2

I'm creating a custom sidebar Google Docs add-on, but can't set its width. I have not published the addon as a web app.

Here's the code:

function onOpen(e) {
  DocumentApp.getUi()
      .createAddonMenu()
      .addItem('Show sidebar', 'showSidebar')
      .addToUi();
}

function showSidebar() {
  var html = HtmlService.createHtmlOutput('<b>Hello!</b>')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME)
      .setTitle('How wide is this?')
      .setWidth(600);  // or 200; neither works - width is always 300px
  DocumentApp.getUi().showSidebar(html);
}

And here's what I get: always a 300-px wide sidebar:

enter image description here

Here's the test document

Rubén
  • 34,714
  • 9
  • 70
  • 166
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
  • 1
    As mentioned in this page: https://developers.google.com/apps-script/reference/base/ui#showSidebar(Object), sidebars shown by scripts are 300 pixels wide. – KRR May 11 '15 at 18:24
  • An alternative, it's possible to use a [modeless dialog box](https://developers.google.com/apps-script/reference/base/ui#showmodelessdialoguserinterface-title) – MagTun Jun 04 '17 at 15:45

1 Answers1

2

As mentioned in this page, sidebars shown by scripts are 300 pixels wide.

KRR
  • 4,647
  • 2
  • 14
  • 14
  • 2
    Why does [the documentation on setWidth](https://developers.google.com/apps-script/reference/html/html-output#setWidth(Integer)) not mention anything about the 300px fixed size? – Dan Dascalescu May 13 '15 at 10:09