I have this simple app and I would like to be able to "catch" the active tab.
For example, if I'm on "tab1", my selectInput at the top would be c("a","b","c") but it would change if I am on the other tab
I want to create a variable active_tab that would be dynamic but I have no idea how to do it.
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = dashboardPage(
title="Shiny Dashboard",
header = shinydashboardPlus::dashboardHeader(
title = "Example",
leftUi = tagList(
uiOutput("reactive_ui")
)),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem("tab1",tabName = "tab1"),
menuItem("tab2",tabName = "tab2")
)
),
body = dashboardBody(
tabItems(
tabItem("tab1"),
tabItem("tab2")
)
)
),
server = function(input, output) {
output$reactive_ui =renderUI({
if (active_tab == "tab1") choice = c("a","b","c","d")
if (active_tab == "tab2") choice = c("e","f","g")
selectInput("select", NULL,choices = choice )
})
}
)