Client Library
Color Theme Compliance (Beta)
UI Functions


You'll almost always need a way to tell Trello that the size of the content in one of your iframes has changed, or maybe doesn't perfectly line up with the height you requested when instantiating the iframe.

For those moments, you can use t.sizeTo(arg)

t.sizeTo takes a single argument which can by any of the following:

stringA DOM query selector that will select the node to measure and use the height oft.sizeTo('#content')
elementA DOM element that will be measured and we will use the height oft.sizeTo(document.body)
numberA positive number that will be used directly for the heightt.sizeTo(625)

To get an understanding of how this is used lets look at an attachment-section example:

  'attachment-sections': function(t, options){
    // options.entries is a list of the attachments for this card
    // you can look through them and 'claim' any that you want to
    // include in your section.

    // we will just claim urls for Yellowstone
    var claimed = options.entries.filter(function(attachment){
      return attachment.url.indexOf('') === 0;

    if(claimed && claimed.length > 0){
      return [{
        claimed: claimed,
        icon: HYPERDEV_ICON,
        title: 'Example Attachment Section: Yellowstone',
        content: {
          type: 'iframe',
          url: t.signUrl('./section.html'),
          height: 230
    } else {
      return [];

Let's look at ./section.html

    <link rel="stylesheet" href="">
    <script src=""></script>
    <div id="content">
      <p>Tips for using attachment-sections</p>
        <li>Make sure your section feels at home on the card. It should fit in with the rest of the card and not stick out.</li>
        <li>You can specify a height when you claim the section, and also use t.sizeTo() to make sure your section is the perfect height.</li>
        <li>Try to keep the height of your sections to a minimum.</li>
        <li>It should be obvious to the user what attachments went into your section. They shouldn't be left wondering were one of their attachments disappeared to.</li>
      <p class="u-quiet">Claimed attachment urls: <span id="urls"></span></p>
    <script src="./js/section.js"></script>

Lastly, let's look at ./js/section.js:

var t = window.TrelloPowerUp.iframe();

  // make sure your rendering logic lives here, since we will
  // recall this method as the user adds and removes attachments
  // from your section
    return attachment.url.indexOf('') == 0;
    var urls ={ return a.url; });
    document.getElementById('urls').textContent = urls.join(', ');
    return t.sizeTo('#content'); // 👈

As you can see, once we have rendered out our section, the last thing we do is call t.sizeTo('#content') to make sure that our section iframe isn't showing as an awkward height and is "just right".

Rate this page: