shiny: start the app with hidden tabs, with NO delay

前端 未结 4 1333
一个人的身影
一个人的身影 2020-12-15 13:24

I would like to build an application and some of the tabs will be hidden to the user until he types the right password. I know how to do this with shinyjs::hideTab

4条回答
  •  既然无缘
    2020-12-15 13:55

    How about this

    library(shiny);library(shinyjs)
    ui <- fluidPage(useShinyjs(),
                    navbarPage("hello", id="hello",
                               tabPanel("home", br(), h3("this is home"),passwordInput("pass", "enter 'password' to see the tabs: "),actionButton("enter", "enter")),
                               tabPanel("tab2",uiOutput("tab2Content")),
                               tabPanel("tab3 with a lot of stuff in it", uiOutput("tab3Content"))))
    server <- function(input, output, session) {
      output$tab2Content <- renderUI({
        req(input$pass == "password")
        tagList(
          br(), 
          h4("this is tab2")
        )
      })
      output$tab3Content <- renderUI({
        req(input$pass == "password")
        tagList(
          br(), 
          h4("this is tab3")
        )
      })}
    shinyApp(ui, server)
    

    hope this helps!

提交回复
热议问题