4

I want to maximise the usable screen width of the mainPanel for an Rstudio shiny webpage.

In my webpage, the sidePanel is used to select parameters to visualise the results in the mainPanel.

I would like to know what can I do to maximise the usable space in mainPanel.

For example, I would like to have a "collapse/expand" option for the sidePanel, so that when collapsed, the entire width of the window is used by mainPanel.

Any ideas?

EDITED:

It turns out sidePanel is a bit tricky, but I can do two different bootstrapPage, and have the one on top for selections that affect the one in the bottom. Then have a collapsible button for it. I'll turn it into an answer unless someone has a more elegant one.

1
  • 1
    I haven't seen anything about a collapsable sidebarPanel. Perhaps you can get some inspiration for an alternative from the new layout features in the the development version of Shiny.
    – Vincent
    Feb 11, 2014 at 18:29

2 Answers 2

5

Only a partial solution but ... if you wrap the div below around the content or your sidebarPanel

div(id = "demo", class = "collapse in", 

)

and then put a button in your main panel as follows

HTML("<button type='button' class='btn btn-danger' data-toggle='collapse' data-target='#demo'>simple collapsible</button>"),

you can collapse the content of the sidebarPanel. This doesn't expand the main panel to take up all the screen however.

2
  • Ok, this would actually be useful if I then had the sidebar as a collapsible header, changing the question.
    – 719016
    Feb 12, 2014 at 9:39
  • 1
    I think so. If your sidebar had an id (would the class work?) then the whole think may collapse. I am thinking this might require using an HTML ui. Another idea might be to put a condition before the sidebar, linked to an action button. Not tested.
    – Vincent
    Feb 12, 2014 at 18:15
0

Perhaps you could work with a toggle-button (e.g. named "set parameters") which opens or closes a conditionalPanel. Such panel then disappears or pops-up when needed. See: https://shiny.rstudio.com/reference/shiny/0.13.2/conditionalPanel.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.