1
votes

I am trying to integrate Rmarkdown text and shinydashboard to create a website. However, after I include a Rmarkdown file in the Shiny app, the width of the website cannot automatically adjust to the size of the window. A reproducible example is listed as below. The exampleMD.rmd is just the simple Rmarkdown template.

body <- dashboardBody(
      fluidRow(
        column(width = 5, box("Box content", width = NULL)),
        column(width = 7, uiOutput('markdown'))
      )
    )

ui <- dashboardPage(
  dashboardHeader(title = "Include Rmarkdown"),
  dashboardSidebar(),
  body
)

server <- function(input, output) { 
  output$markdown <- renderUI({
  HTML(markdown::markdownToHTML(knit('exampleMD.rmd', quiet = TRUE)))
  })
}

shinyApp(ui = ui, server = server)

Rendered Shinydashboard

The resulting dashboard looks fine, but however I change the size of the window, the width of the dashboard is fixed and cannot automatically adjust according to the width of browser.

I wonder if there any solutions to this fixed window. Many thanks!

1

1 Answers

1
votes

add this to your Rmarkdown:

<style type="text/css">
           body {          
           max-width:100%;
           padding:0;
           }
</style>