dsz
dsz

Reputation: 5202

Getting Shiny (RMarkdown) to use full browser window

Using RStudio 0.98.1028 on R 3.1.1 on Windows 7 64 bit, creating an interactive document using Shiny's fluidPage, sidebarLayout and sidebarPanel. They all play nicely and as described on small-ish window sizes, but when I go full-screen with either RStudio's built-in browser or with a web-browser (IE 11), there is a massive (about 40%) area of just white-space on the left of my window that isn't being used. What can I do to make Shiny use ALL of my browser window width?

Test case:

---
title: "TestBed"
author: "Derek Slone-Zhen"
date: "Tuesday, September 02, 2014"
output: html_document
runtime: shiny
---

```{r echo=FALSE}
shinyUI(fluidPage(
  titlePanel("title panel"),

  sidebarLayout(
    sidebarPanel(

            actionButton("goButton", label="Submit")
      ),
    mainPanel(
        renderDataTable({
          input$goButton
          mx <- 1:10000
          dim(mx) <- c(100,100)
          mx <- as.data.frame(mx)
          mx
        } 
      )
    )
  )
))
```

What I don't like the look of:

enter image description here

Upvotes: 3

Views: 2418

Answers (1)

jdharrison
jdharrison

Reputation: 30425

You may need to run the dev version of rmarkdown so

devtools::install_github("rstudio/rmarkdown") 

see https://github.com/rstudio/rmarkdown/issues/135

Change your yaml header to:

---
title: "TestBed"
author: "Derek Slone-Zhen"
date: "Tuesday, September 02, 2014"
runtime: shiny
output:
  html_document:
    css: my.css
---

Then you can add a CSS my.css in the same directory as your .Rmd file. By default the markdown is placed in a bootstrap fluid container having class = main-container with default styling margin-left: auto;. You can change this for example

my.css:

.main-container{
  margin-left: 0px !important;
  } 

which results in:

enter image description here

Upvotes: 4

Related Questions