How to change tabPanel width in a shinyDashboard layout?

Viewed 757

I am currently designing a Shiny App with the package shinydashboard.

I am using a tabsetPanel layout and I cannot change the width of each tabPanel so that the plot fits the entire window width. The value put in the argument width = seems to have no influence on it.

I already tried all the solutions given in the question : Shiny: How to adjust the width of the tabsetPanel?, but none of these worked for me.

Here is my code :

library(shiny)
library(shinydashboard)


header<-dashboardHeader(title="Shiny App")

sidebar<-dashboardSidebar()

body<-dashboardBody(
  fluidRow(
  mainPanel(
    tabsetPanel(
      tabPanel("Panel1",
          box(plotOutput("plot"),height=420,width = 1400)
      )
    )
  )
  )
)

ui<-dashboardPage(header,sidebar,body)

server<-function(input,output) {
  output$plot<-renderPlot({plot(1)})
}

shinyApp(ui,server)

Whatever the value of the width, I have got this size of tabPanel. I cannot figure out how to change it.

View of the Shiny App

Could you help me? Thanks!

2 Answers

Please try this.

library(shiny)
library(shinydashboard)

header<-dashboardHeader(title="Shiny App")

sidebar<-dashboardSidebar()

body<-dashboardBody(

      tabsetPanel(
        fluidRow(
          tabBox(id = "tabset1", height = "650px", width=12, title = "My Box Size",  ## change box size here
                 tabPanel("Panel1",
                          fluidRow(
                            column(12, plotOutput("plot",height=420, width=600)) ## change plot width here
                          )
                 )
      )))

)


ui<-dashboardPage(header,sidebar,body)

server<-function(input,output) {
  plot1 <- qplot(rnorm(500),fill=I("red"),binwidth=0.2,title="plotgraph1")
  output$plot<-renderPlot({plot1})
}

shinyApp(ui,server)

You can try this approach

header<-dashboardHeader(title="Shiny App")

sidebar<-dashboardSidebar()

body<-dashboardBody(
  fluidRow(
    mainPanel(
      tabsetPanel(
         
        tabPanel("Panel1",
                 box(plotOutput("plot", width = 950, height = 100)))
      )
    )
  )
)

ui<-dashboardPage(header,sidebar,body)

server<-function(input,output) {
  output$plot<-renderPlot({plot(1)},height = 500)
}

shinyApp(ui,server)
Related