Documentation for Confluence 5.8 (Server).
Documentation for Confluence Cloud 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

96 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?

    1. I second this! It would be a very useful feature.

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

    1. Can I have an expandable option box? I mean when i expand, I need some status options for users to choose. Would that be some other macro?

      1. If this could be helpful, take a look on this: https://wiki.uef.fi/display/~ryokas@uef.fi/Expand+tests

        The idea is, that it is not necessary to the visitor to know, it doesn't exists any really choises. With expand one can get a look-a-like "which option" look.

        Any better solutions?

        1. Thanks for the idea. I guess I am looking for a drop down set of choices for the users to choose.

          So, user comes in, looks at the table, finds his row. Goes to Colum6 which is the status column and selects one of the status from the drop down list (started, completed, testing.. something like that)

  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.

        1. I needed a slight modification in order to get this to work for me. I had to move a }); block up to close the toggle function. Moved line 53 between 27&28; otherwise, expand and collapse only worked after clicking toggle. Not sure if that was intended for your actions but personally I removed toggle so it wasn't the behavior I wanted. Thanks!

        2. Thanks for the code. It did not work for me in a macro tho and changed the toggle part. I also moved those brackets up from 53 to 27f.

          Then I created the following user macro that does the job (tested in 5.4.3):

          Best regards,

          George

          1. Works well!  Great job!

  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

    1. KM

      Could the title be a link?
      Now in C5.7 the content can be links, but I'd need to make the title a link (to a page; the content is links to its subpages).

      1. Hi KM,

        Unfortunately, no, not that I'm aware of. Sounds like you could use the Children Display Macro to do that job, but the list would always be expanded.

        You could think about making a suggestion for a collapsed option for the Children Display macro.

        1. KM

          That would solve some of the problems (a collapsed option in the Children Display Macro). Sometimes I want to be able to manually select the tree structure, different from the page structure. That is when I'd need expand macro with the title as a link. The Expando macro mentioned below would also solve some but just some of the problems, but it seems to be partially discontinued.

  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?

  29. Hello there, I wonder is it possible to make the expand macro be expanded by default? That means, when a user open the page, contents inside the macro could be displayed by default?

    1. Sorry, that is not currently possible.  There is a ticket about this that you can watch / vote on here  CONF-27077 - Option to display expand macro expanded/collapsed on page load Open .

  30. Is it possible to use an image for the title field of the expand macro? If so can you please provide sample code.

    1. The macro itself won't allow you to, but if you really need to you can use jQuery to replace the text with an image.

      I've gone into the Custom HTML in the admin panel and added this to "At end of the HEAD"

      The first half is someone else, that fixes the generic error if an anonymous user clicks a check box by forcing them to log in.

      The second half replaces all {IMG:url} in the expand text with an image tag.

      Example:

       {IMG:https://www.google.com/images/srpr/logo11w.png}

       

      Since I can't run JavaScript here it won't display but on mine it will show up as the Google logo. 

      1. I do not know how to access the "Custom HTML in the admin panel" can you provide guidance?

        -disregard I think my version doesnt offer the Custom Html under look and feel (sad)

        Thanks so much for all your help (smile)

        1. Hi Loreal, if you are an OnDemand customer HTML macros are not available for security reasons.  If you have installed Confluence, then your administrator can choose to enable the HTML macros - these are disabled by default. There is more info on the HTML Macro page. 

  31. I've placed several anchors in expand macros, but unfortunately I can't have pages redirect to these anchors. How can I make this work?

    1. Hi Maarten, I think an issue has been raised about this previously  CONF-27357 - Anchors should link to an expanded content instead of staying closed Open .  From my quick test it looks like a link to an anchor will only go to that anchor if it the expand is already expanded on the page - and there is no way to default the expand macros to expanded.  Sorry!.

    2. Hi Maarten,

      maybe you could try the workaround I posted in the associated JIRA ticket:  CONF-27357 - Anchors should link to an expanded content instead of staying closed Open

  32.  Hi,

     Is there any way to collapse the Expand macros instantiated within a page when in Edit mode? Its a bit difficult to edit a page with multiple expands that wrap around each other (sad)

     Thank U,

    Ionut 

     

    1. Hi Ionut, sorry there's no way to collapse the macros in Edit mode. 

  33. When you export to PDF, the section is expanded, however, the 'Click here to expand' text is also included, which makes no sense for the PDF. Is there any way to remove this text in the PDF output? The documents are also read online, so I don't want to delete the text for when it is viewed online...

  34. You can disable the text with following css code. Refer to Customising Exports to PDF for more information about using it.

    1. Works perfectly, thanks Bernhard (smile)

  35. is there a css that shows the expand title but hides the text within when doing a pdf export?

  36. I have a page where I need to include multiple expand macros (around 20) and each expand macro is linked to another page.  I noticed with this setup, it usually takes a long time for the page to load.  Is there any way to make the page load faster?

    1. Hi Michael,  I haven't seen this behaviour on pages with a lot of expand macros (but I'm not quite sure what you mean by linked to another page). If you could raise a bug  with some more information (and maybe an example of how you've got the expands set up) our team can investigate. 

      1. Hi Rachel, thanks for the response.  Here's the layout of the page.  There are basically 20+ "Expand" macros.  Each "Expand" macro has a "Panel" macro inside.  Within each "Panel" macro is an "Include Page" macro (each of which is linked to a different page).

        Basically when I click on the link to this page, it takes over a minute and a half to load.  I'm guessing because it needs to load all the different pages for each expand macro.  But is there a way to make the page load faster?

  37. Is there a way to change the default text from "Click here to expand..." to "Click here to view a screenshot..."?

     

     

    1. Yes. We used it here: https://wiki.uef.fi/display/Theologyhomes/Images+of+the+School++-+Osasto+kuvina

      You can edit it as a part of editing the "Expand" macro, or with Wiki Markup. Unfortunately, it is no more possible for me to reproduce, how we did it ...

    2. Yes, just as Esko said, when you edit the Expand Macro, there will be an option, under the "Title" heading, for you to change the text to anything you like.

      1. I was looking for a way to have the default text automatically be "Click here to view a screenshot..." 
        Because we are not using the current default text - "Click here to expand..." - I edit the text manually each time I add an expand macro. If there was a way to set that default text, that would make my work more efficient.
        1. Hi Paul, Michael, and Esko,

          I'd say the answer would be to build your own add-on, as the default text will be in the code of the add-on, with no way to edit it in the UI.

          You could also try asking over at answers to see if anyone's already done this.

  38. As a Confluence Administrator you can add following User Macro:

    1. Thank you so very much!!! I never thought to try and create a macro.

  39. Let me take this a step further. We use "Click here to view a screenshot..." on multiple pages - for this example, 20. I was trying to think of a way to store just the text "Click here to view a screenshot..." as the link to expand a drop-down. The reason I want to store that as a snippet is that if we decide that "Click here to view a screenshot..." needs to be changed to something else - perhaps "View a screenshot" - we wouldn't have to change those 20 pages.

    If there isn't a way to do what I'm asking, how would you approach this?


  40. I'd like to request an enhancement to the Expand macro: I'd like the macro to

    1. display text up to x many characters (that I'm able to specify)
    2. and display a "more" link (that would expand & display the additional / hidden text) when the character count surpasses the default or my specified character count 
    3. by default, text is hidden behind "more" until clicked.

    Anyone else have that need? Or know of an existing way to accomplish this? 

    thanks, 

    John 

    1. I like to support this suggestion.

      I work around this missing functionality with a combination of excerpt/ excerpt-include and the expand macro. Quite a hazzle for a functionality which every similar product has but not Confluence.

  41. KM

    This "show N first characters" option would be needed in at least the following macros:

    • Expand
    • Include
    • Excerpt Include
    • Recently Updated
    • Recently Updated Dashboard
    • (Children Display, Page Tree)

    Preferably, there would also be options for "more" and "go to" links (even both could be chosen).

    Preferably, there would also be "show M first sentences" and "show K first paragraphs" options too. (If more than 1 option chosen, they all restrict the amount shown, i.e., the tightest applies.) I would typically have at most 1 paragraph, at most 3 sentences, at most xxx characters.

    For example, I often want to show the top of a user-edited blog-type page, and I cannot require the users to use the Excerpt macro. I could use "Include" with N first characters to show most recent items of several such pages on a Home page.

  42. Is there any way to "format" the expand "title"?

    I've tried the solution discussed between Hanna Nelson/Dhyana Scarano from 2011 (listet as the very first comment above), but this doesn't work for me - maybe it's because we use Confluence 5.7.1.?

    Would be nice to have an "formatting" option in the macro itself to give at least one of the "standard" formats from Confluence (h1-h6, p, cite, code) ... or need to use some Add-Ons from third-party vendors (but they somtimes run in other problems ...) ...!

    Additional: Maybe some option to change the "toggle"-icon?

    Voting for the "expand/collapse all"-function from Jun 12, 2012!

    Thx & regards!

    1. Hi Thomas,

      Your best bet for styling the expand macro is using space or global CSS. I've done it previously to change the appearance, and it works well.

      As far as expand/collapse all, I don't think it applies to the expand macro, as it only has one expandable/collapsible section.