shiny on web with invisible tab/part to users

,

...Hello

I would like to upload a basic shiny app in the web (somewhere free) with say five tabs, but i want users to see only 4 of them, the last one is the metrics of the app only for my internal use. Then how can it be invisible to users but not to me?

Thank you

You should add a simple login widget (passwordInput) and upon entering the correct password, the fifth tab can be made visible. It would also require you to create the ui for the fifth tab on the server side so that it appears conditionally.

1 Like

This is not exactly what you want, but it might be close.

library(shiny)

ui = fluidPage(
  passwordInput(
    inputId = 'pwd',
    label = 'Enter password'
  ),
  tabsetPanel(
    tabPanel(
      title = 'tab1',
      h1('This is tab 1')
    ),
    tabPanel(
      title = 'tab2',
      h1('This is tab 2')
    ),
    tabPanel(
      title = 'tab3',
      uiOutput('uiTab3')
    )
    
  )
)

server = function(input, output, session) {
  
  output$uiTab3 = renderUI(
    if (input$pwd == '123') {
        h1('This is tab 3')
    }
  )
}

shinyApp(ui, server)
1 Like

Thank you very much. It looks nice. Please let me do a try and come back to you. I will see how to add an ui for a specific tab.

hello ! i did a try but it does not work for several reasons:

  • the tab is viewed even without the password
  • once the password is entered, nothing happens
  • the password is required at every tab but directed for tab3 only

do you have an explanation? thank tyou

the tab is viewed even without the password

The tab will appear in the tab list even if the page has not been "unlocked" by the password. Does the hidden content that is rendered in the server's renderUI() show before the password is entered?

once the password is entered, nothing happens

This might require more information on what your implemented code looks like (with all the sensitive content removed) to diagnose.

the password is required at every tab but directed for tab3 only

In the example, the password field is outside of the tabsetPanel()and therefore appears independently of what tab is currently selected. This is a valid implementation but may not match what you envision for the design.

If you prefer the password field to only appear in the relevant tab, simply move the password field to be inside that tab.

ui = fluidPage(
  tabsetPanel(
    tabPanel(
      title = 'tab1',
      h1('This is tab 1')
    ),
    tabPanel(
      title = 'tab2',
      h1('This is tab 2')
    ),
    tabPanel(
      title = 'tab3',
      passwordInput(
        inputId = 'pwd',
        label = 'Enter password'
      ),
      uiOutput('uiTab3')
    )
    
  )
)

If you want the password field to also disappear after the correct password is entered, you'll need to either hide the password field element using JavaScript/shinyJS, or have the password field rendered by the renderUI when the correct password has not yet been entered.

Thank you for your explanations.