Expandable panel with preview?
Asked by David Angelovich:

Is there a way I can get a panel with quite a bit of text that will initially display x lines of the contents, or the full text if expanded?

I want to show command line commands/output, but most of the time only the first 2 line of the example are important - but displaying the 50-line output in full makes the page look messy.

The expand macro seems close-ish, but really not suitable. Ideally, I need an expansion of the noformat or code panels.  
[](https://community.atlassian.com/t5/Confluence-questions/Expandable-panel-with-preview/qaq-p/347505?attachment-id=11301){#link_11866077628080}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58719/1/image2016-9-15%2013%3A36%3A13.png){#display_11866077628080_0}  
[](https://community.atlassian.com/t5/Confluence-questions/Expandable-panel-with-preview/qaq-p/347505?attachment-id=11302){#link_11866077628080_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58719/2/image2016-9-15%2013%3A36%3A52.png){#display_11866077628080_2}  
[](https://community.atlassian.com/t5/Confluence-questions/Expandable-panel-with-preview/qaq-p/347505?attachment-id=11303){#link_11866077628080_1}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58719/3/image2016-9-15%2013%3A37%3A24.png){#display_11866077628080_4}


Answers:
author: Milo Test
body: I had another idea. Use the show excerpt option of the Content by Label macro.

Create a page with the code, duplicating some of it in an Excerpt macro, and add one or more labels to the page:

image2016-9-15 13:22:47.png

*** ** * ** ***

image2016-9-15 13:21:44.png

Then on the target page, put the Content by Label macro in a Panel macro, add at least one label to search and select the option to display an excerpt:

image2016-9-15 13:37:24.png

The user can then select the code (even using the doubleclick ability of the code block macro, or click on the excerpt title ("Some code" in this case), to see the full code.

Another benefit to this method is that you can add instructional text to the code page and you can reuse the code page on multiple pages, and if you need to edit the code, it will automatically update on every page that includes it.  
[](https://community.atlassian.com/t5/Confluence-questions/Expandable-panel-with-preview/qaq-p/347505?attachment-id=789){#link_1186607c0569e8}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58721/1/image2016-9-15%2013%3A21%3A44.png){#display_1186607c0569e8_0}  
[](https://community.atlassian.com/t5/Confluence-questions/Expandable-panel-with-preview/qaq-p/347505?attachment-id=790){#link_1186607c0569e8_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58721/2/image2016-9-15%2013%3A22%3A47.png){#display_1186607c0569e8_2}  
[](https://community.atlassian.com/t5/Confluence-questions/Expandable-panel-with-preview/qaq-p/347505?attachment-id=791){#link_1186607c0569e8_1}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58721/3/image2016-9-15%2013%3A20%3A55.png){#display_1186607c0569e8_4}


author: Milo Test
body: You can certainly put the Expand macro within the Panel macro. You can even put the Code Block macro in the Expand macro. Though you can't really make only part of it show, you can change the "Click here to expand..." text to whatever single line of text you want, but it might not be clear that it's part of the code:

image2016-9-14 15:20:10.png  
[](https://community.atlassian.com/t5/Confluence-questions/Expandable-panel-with-preview/qaq-p/347505?attachment-id=4998){#link_11866081abd0bd}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/58720/1/image2016-9-14%2015%3A20%3A10.png){#display_11866081abd0bd_0}