Documentation for Confluence 5.4.
Documentation for Confluence OnDemand and earlier versions of Confluence is available too.

Skip to end of metadata
Go to start of metadata

The Expand macro displays an expandable/collapsible section of text on your page.

Here is an example:

 Expand me...

This text is hidden until you expand the section.

Using the Expand Macro

To insert the Expand macro into a page using the macro browser:

  1. In the Confluence editor, choose Insert > Other Macros.
  2. Find and select the required macro.

Speeding up macro entry with autocomplete: Type { and the beginning of the macro name, to see a list of suggested macros. Details are in Using Autocomplete.

To edit an existing macro: Click the macro placeholder and choose Edit. A macro dialog window will open, where you can edit the parameters of the macro.

Parameters

Parameters are options that you can set to control the content or format of the macro output. Where the parameter name used in Confluence storage format or wikimarkup is different to the label used in the macro browser, it will be listed below in brackets (example).

Parameter

Default

Description

Title


Click here to expand...

Defines the text that appears next to the expand/collapse icon.

Code examples

The following examples are provided for advanced users who want to inspect or edit the underlying markup for a Confluence page. 

Macro name: expand

Macro body: Accepts rich text.

Storage format example

Wikimarkup example

Notes

  • Text is expanded in PDF and HTML exports. When you export the page to PDF or HTML, the text between the macro tags is expanded so that readers can see it in the PDF and HTML versions of the page.
  • Nesting your Expand macros. You can put one Expand macro inside another, and Confluence will correctly show and hide the contents of all Expand macros, including the nested ones.
  • No labels

55 Comments

  1. Is there a way to add formatting to the title?  For example, I'd like to use this feature for "See also" lists.  I changed the title to "See also", but would like to make that title bold and/or a color from the theme.

    1. Hi Hanna,

      I've found that headings will still work with the expand macro e.g.:

      Wiki markup:

      Result:

       Click here to see the text...

      This text block will expand and collapse.

      But other text formatting markup seems to not work inside the "title" parameter:

      Wiki markup:

      Result:

       *Click here to see the text...*

      This text block will expand and collapse.

      However, using the {span} macro wrapped around the entire {expand} macro seems to work as long as you use a new line after the first {expand:...} tag and before the expanded text.
      (Note: it doesn't work in my version of Confluence 3.3.1 but it seems to work in this one).

      Wiki markup:

      Result:

      Unknown macro: {span}
       Click here to see the text...

      This text block will expand and collapse.

      1. Thanks Dhyana.

        The heading solution is elegant but causes all the text in the expand to also appear as a heading. 

        The span doesn't seem to work in my version (3.4.9) - maybe it's a 3.5 thing?

      2. Just coming to Confluence in 4.2. One can't edit the markup in v4. So that means we can have headings in expand titles any more it seems (sad)

      3. Do you have equivalent for source editor in 4.3 ?

  2. Is there a parameter that allows the default to display expanded rather than collapsed?

  3. Can you make option box - default expanded or collapsed?

  4. Anonymous

    (Suggestion for improvement) How about a separate parameter to provide text to display when expanded?

  5. Anonymous

    Is there a way to expand all your expands on a page? = an expand all and collapse all function?

    1. That will be great.. i vote for that too

      1. Anonymous

        1. Anonymous

          I would like that feature too!

    2. Anonymous

      Voted! We really would like an "expand all" functionality.

    3. Anonymous

      I totally agree. I came to this page to figure out how I can "expand all" for a page.

    4. Anonymous

      I figured out how to do it with some custom code.  Put this line somewhere on the page in an HTML block. 

      <a id="toggleAll" href="#">Expand/Collapse All</a>

       

      Then at the bottom of the page create another HTML macro and add the following code. 

      <script type="text/javascript">
      AJS.toInit(function ()
      {

      AJS.$('#toggleAll').click(function()
      {

      jQuery(".expand-control").each(function(){ jQuery(this).trigger("click");})

      });

      });
      </script>

      This will use jQuery to automatically trigger the expand or collapse.  One problem is if you have something expanded already and then click this button. It will collapse all that are expanded and will expand all that are collapsed. So it doesn't work perfectly but a lot better. 

      1. A slightly modified solution - this uses the actual function that gets attached to each item - that includes explicit expand and collapse, as well as the toggle.

        I ended up putting everything in one HTML block, rather than the two originally suggested. 

        This could be further optimized to reduce some of the copy-paste code (mainly by parametrizing the click handler to all for passing of expand/collapse into a single function, rather than the three functions), but works well enough for my needs.

  6. Anonymous

    It seems the markup isn't working if umlaute (ä, ö, ü) are in the title.

  7. Anonymous

    Can I take a table of URL(SEO URL list) and use the expansion macro for each url to describe details around Meta Data etc and still have it display in a table format?

  8. Create an user macro with the following code:

    ...

    ## @noparams

    <style type="text/css">

    .expand-control-text {

    font-weight:bold;color: #2438BB;

    }

    </style>

    or a css-style-sheet:

    .expand-control-text {

    font-weight:bold;color: #2438BB;

    }

    The header of the expand-macro will appear bold and blue.

    1. Anonymous

      Thanks!  (smile)  I've been looking for this for awhile and it was so easy.

    2. Header font is changing with css but can we apply css for the text inside the expand macro?

  9. Anonymous

    This doesn't work for me. I only see the default title "Click here to expand..." no matter what I put in.

    E.g.

    still shows like this:

     Click here to expand...

    This text block will expand and collapse.

    1. Anonymous

      Found how to solve this. Leave out the "title=" bit:

  10. Anonymous

    Aside from formatting, there are a few other frustrating inconveniences when using the Expand macro...

    1. If you search within a doc that has Expand sections that are collapsed, the search won't find the content within those sections
    2. If you create an Anchor to a specific location within an Expand section and that section is collapsed, any link to that anchor won't function unless the section is expanded

    The second item is especially frustrating...If anyone knows a work around I'd be especially grateful.  Ultimately if this could be addressed properly in the next update, that would be great too.

    1. Anonymous

      Yah, a search function that opens cloaks or expand macro's would be great! We have built a large page that is cloaked and expand macro'd and we can't seem to search our cloaked and/or expanded sections. Any further word or suggestions for a different way of doing this with what is already built into confluence or even a plugin that exists would be AMAZING! Thanks for your time

    2. Point 2 shown here would be a great addition, I have tried numerous methods to achieve this utilising existing Macros but am somewhat restrictied as I am using a hosted version of confluence. Does anyone have a workable solution to be able to nest an anchor within the expand section and when calling this anchor make the section auto collapse?

       

  11. Anonymous

    有没有办法解决在应用端编辑宏时,改变标题字体格式?

  12. Anonymous

    Hi (smile) it possible to make your title a different size from your content? I need my text to be quite large for my title only this also makes my content within the expand large as well, is it possible to give the title an independent size?

     

    Thanks (smile)

    1. If it concerns the expand-control-text look at my proposition; otherwise you must use html-code or a division with css

  13. Anonymous

    Is there a way to put various Expand in a single page and when I click on one Expand any other expand in the page or inside another macro get collapsed?, I'm making a Glosary and I put autoadjustable columns and inside each collum and expand with an Include Page, so when I click in Expand A it shows the glosary for this letter, and when i click on Expand B it shows the content of page for the letter B but it doesn't collapse the first collapse, and with this logic i can have all the alphabet open at the same time.

    Regards, and sorry about my bad english!

  14. Anonymous

    Embedding this macro in the site welcome message doesn't work for me. Can anyone else confirm that the dashboard cannot display this macro?

    1. Hallo there Anonymous

      I'm not sure about the dashboard, but I did notice that the Expand macro stopped working in the sidebar in the Confluence Documentation theme. That problem was fixed in Confluence 4.3.5 (just released). You can see it working at the bottom of the left-hand panel on this page, where it says "Choose a version...".

      Cheers, Sarah

  15. Is there a way to not run the code under the expand macro until the macro is clicked? I use expand to hide the results of a report. I have a page with 60 small reports on it, each is hidden using an expand. The page takes a long time to load because it is rendering and hiding all the reports. As I have more data in my database to be searched for a report (or more reports on the page) the page will take longer to load. 

    Fred

    1. Hallo Fred

      The Cache macro, by Bob Swift, can help you here. It delays the rendering of a part of the page so that the rest of the page can load faster:

      https://marketplace.atlassian.com/plugins/org.swift.confluence.cache

      I hope this helps!

      Cheers, Sarah

  16. Anonymous

    The expand macro is not working for me in certain situations.

    It works on my personal page (a sandbox copy)

    It works in the preview of the "production" page. 

    It works in the preview from the macro dialog.

    However, in the actual production page, I see the text "click to expand" and then the full contents of what is in the expand block. It cannot be expanded nor condensed.  I have tried removing and recreating the macro several times. The block contains several JIRA macros and text.

    The only difference I can see in the production page versus my sandbox is the layout. Production has a left sidebar. 

    Any thoughts?  Thank you!

    1. Hallo there

      It sounds as if some CSS is overriding the expandability. Are you using a specific theme in the production version (a theme may be adding that left sidebar) or has someone applied custom CSS to the space?

      Cheers, Sarah

  17. Anonymous

     

    Is it possible for the content in the expand be a link? Example below where Page 1 and 2 is a link to the respective pages. Doesn't seem to allow this at the moment, but did with past version.

     Iteration 1

    Page 1

    Page 2

  18. Anonymous

    Like many comments on the current page, I think that having an expand all option (like for bottom page comments) OR having a property like expended=true would be so nice.

    I hope anyone will read this and think this is a good idea.  (smile) Thanks.

     

    A fan of your products.

    1. I agree 100% Anonymous.

  19. Anonymous

    Is there a way to have an expand function in an already created expand macro?

    1. Hallo Anonymous

      It depends on your version of Confluence.

      If you are on Confluence 4.3.2 or later, you can put one Expand macro inside another.

      If you're using Confluence 3.5 or earlier, you can create your own user macro to allow nesting. See this blog post: http://ffeathers.wordpress.com/2011/08/20/nested-expand-macros-in-confluence-wiki/

      If your Confluence version is between 4.0 and 4.3.1, it's not possible to nest the Expand macros.

      Cheers, Sarah

  20. Some of the mentioned feature requests on this page are similar to this on, but not the same: It would be great, if one could link to an opened expand-macro.

    I have a list of collapsed content, like a FAQ, and would like to send users directly to one of the items which in this case should be presented opened. The solution might potentially be an addition in the URL, but I don't know, if this is possible at all.

    If Yes: Thanks for any hint.

    If No: Are there any plans related to the described requisition?

    Sven

  21. Should I be able to nest other macros - e.g. HTML or Table - inside an Expand macro?

  22. I would like to see the same functionality added as Sven Meyenburg described.

  23. I have just blogged about our alternative Expando macro, that allows toggling of headings and expands sections based on the hash value in the url: http://blog.k15t.com/2013/07/expando-macro-for-confluence%3A-collapse-and-expand-headings.

    It's free and open-source. I am looking forward to read your comments!

  24. In 5.2 the Expand macro allows more than text, i.e. also a picture can be opened.

  25. We have a user that has created a page, that has 6 instances of this macro in use.  In 4 of the instances, clicking on the hyperlink briefly shows the text, then it is hidden again.  2 of the instances are working fine, in that clicking on the hyperlink, expands to show the text.  Clicking it again, hides the text.

    I'm afraid I'm not a user of the wiki, nor familiar with the macros, and am posting this here on our user's behalf.  

    Thanks in advance.

  26. Is it possible to implement bold font and different color for the text in expandable macro? 

      1. But if you put your text as a photo, it's works. Then you have any possibilities.

        1. We cannot put the text as photo as this will restrict the usability of macro.

          1. this is true and not a nice solution. But you can put a link to your photo (which looks like a text), too

  27. Is it possible to point to a particular Expand Macro (EM) on any page when I have a multiple of them ?

    For example, if I have 3 EMs on any page and from another page if I would like to come directly to the

    second EM thru a link - is that possible?

    If not, is there any other macro which will inserting simple texts and still allow me to come to the beginning

    of a specific text area from another page thru links?

    1. Hi Tirthankar, I'm not aware of a way to link to a page in a way that the expand is triggered.  The closest I could get was placing an Anchor macro directly before the expand - the user would land at the right part of the page, but would still need to click the expand to open it. 

      There's information about using anchor links here - Working with Links

      You could also post your question on Answers, as someone from the community might have a workaround for this. 

  28. I've seen a number of requests for this, but I'm throwing my hat into the ring as well....we need the ability to have the expand macro expanded by default, then users can collapse if they choose to. I see there have been some work-arounds posted where it provides a collapse all / expand all, but what I need is specifically for the content to be all visible when the page loads, and collapsed upon the user doing so. Any help here?