简体   繁体   中英

shiny R app menuitem inside conditional panel deformed

I have this shiny app with 4 menuItem. One is named "Login" and tabA, tabB, and tabC are under a conditionalPanel and only appear when a login is successfully done.

在此处输入图片说明

Can someone give a hint on why the UI has changed? Because all 4 tabs should look exactly as the first one.

ui.R code:

menuItem('Login', tabName = 'Login', icon = icon('fa fa-address-book')),
conditionalPanel(" 'TRUE' === 'TRUE' ",                                              
               menuItem("tabA", tabName = "tabA", icon = icon("fa fa-book")),
               menuItem("tabB", tabName = "tabB", icon = icon("fa fa-line-chart")),
               menuItem("tabC",  icon = icon("fa fa-database")))

Thank you in advance

One option should be to wrap with sidebarMenu

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(
    title = "Shiny"
  ),

  dashboardSidebar(
    sidebarMenu(id="menu",
                menuItem('Login', tabName = 'Login', icon = icon('user-o')),
                conditionalPanel(" 'TRUE' === 'TRUE' ",  
                sidebarMenu(menuItem("tabA", tabName = "tabA", icon = icon("quora")),
                menuItem("tabB", tabName = "tabB", icon = icon("superpowers")),
                menuItem("tabC", tabName = "tabC", icon = icon("podcast"))))
    )
  ),

  dashboardBody(
    tabItems(
      tabItem("Login",h1("login")),
      tabItem("tabA",h1("a")),
      tabItem("tabB",h1("b")),
      tabItem("tabC", h1("c"))

    )


  )
)


server <- function(input, output) {
  observe(print(input$menu))
}

shinyApp(ui,server)

giving output

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM