Z B
Z B

Reputation: 131

two tabs or more using shinydashboard package

can any one build in that below very simple shiny dashboard another tab where we can have other sliderbar, other output.....etc.i am realy confused.

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title="Tab1"),
  dashboardSidebar(    width = 230,
sidebarMenu(
  fileInput("df",
              label="Upload FCM Data"
              ),
  fileInput("dl",
            label="Upload Device AX Data"
  ),
  
  uiOutput('choose_TEC'),
  uiOutput('choose_OP'),
  uiOutput('choose_APL'),
  uiOutput('choose_PRD'),
  uiOutput('choose_DEV'),
  uiOutput('choose_NACol')
)),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)

Upvotes: 0

Views: 2456

Answers (1)

Quinten
Quinten

Reputation: 41225

I created just an example dashboard with two tabs using tabPanel. You can use the following code:

library(shiny)
library(shinythemes)
library(shinydashboard)

shinyApp(
  ui = navbarPage("Dashboard", theme = shinytheme("flatly"),
                  tabPanel("Tab1",
                           sidebarLayout(
                             sidebarPanel(
                               fileInput("df",
                                         label="Upload FCM Data"
                               ),
                               fileInput("dl",
                                         label="Upload Device AX Data"
                               ),
                               
                               uiOutput('choose_TEC'),
                               uiOutput('choose_OP'),
                               uiOutput('choose_APL'),
                               uiOutput('choose_PRD'),
                               uiOutput('choose_DEV'),
                               uiOutput('choose_NACol')
                             ),
                             mainPanel(
                               h2("text tab 1")
                             )
                           )
                  ),
                  tabPanel("Tab 2",
                           sidebarLayout(
                             sidebarPanel(
                               sliderInput("slider1", label = h3("Slider"), min = 0, 
                                           max = 100, value = 50)
                             ),
                             mainPanel(
                               h2("text tab2")
                             )
                           )
                  )
  ),
  server = function(input, output) { }
)

Output looks like this:

enter image description here

Upvotes: 1

Related Questions