Including tabset panel in sidebarPanel of shiny
Asked Answered
B

1

6

I'm using the package shiny to create an app. I would like to include a tabset panel in my sidebarPanel, like tabsetPanel() does it for the mainPanel() in the user interface. Does anyone knows if or how this work?

Thanks in advance!

Baseless answered 3/1, 2014 at 11:30 Comment(0)
P
5

mainPanel or sidebarPanel are just a wrappers for a div tag, a sort of html container where you can put any other html valid elements.

For example, you can do this:

library(shiny)
ui <- pageWithSidebar(
  # Application title
  headerPanel("Hello Shiny!"),
  # Sidebar with a slider input
  sidebarPanel(
    tabsetPanel(
      tabPanel("Plot", plotOutput("plot")),
      tabPanel("Summary", verbatimTextOutput("summary")),
      tabPanel("Table", tableOutput("table"))
    )),
  # Show a plot of the generated distribution
  mainPanel(
    plotOutput("distPlot")
  )
)

server <- function(input,output){}

runApp(list(ui=ui,server=server))
Phyllys answered 3/1, 2014 at 12:18 Comment(1)
This is working fine but how does shiny know just to print the plot when the tabPanel "Plot" is chosen and not giving the "Summary" and "Table" as well. I added tabsetPanel(id="tabname",...) and choose a conditionalPanel(...) in the mainPanel(...) but it still gives all outputs at once.Baseless

© 2022 - 2024 — McMap. All rights reserved.