Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch between the tabItems shiny dashboard

I'am in the process of creating a shiny dashbord, I create 3 tabItems the problem is that when I click on one of the menuItem I can not click on again, i can't switch between the tabItems . Can someone help me please the code R #UI

 library(shiny)
 library(shinydashboard)

 shinyUI(dashboardPage(skin = "black",
 dashboardHeader(title = h4("Tableau de bord des élections",style =      "color:navy"),
 titleWidth = 300
 ),
 dashboardSidebar(id="", 
 menuItem(h4(strong("Dashboard", align = "center")), tabName = "dashboard"),
 menuItem(h4(strong("Prédiction")), tabName = "Prédiction"),
 menuItem(h4(strong("Interprétation")), tabName = "Interprétation")),



 dashboardBody(
    tabItems(
        tabItem(tabName = "dashboard",h2("Analyse du comportement électoral  des citoyens tunisiens", align="center",style = "color:navy") ),

        tabItem(tabName = "Prédiction", h2("Prédiction du vote",    align="center",style = "color:blue")),
        tabItem(tabName = "Interprétation", h2("Interprétation"))

        )
        )))
like image 516
Asma Avatar asked Feb 07 '23 09:02

Asma


1 Answers

I know that your problem has been solved and that you probably won't change your code ~1years later, but for others like me encountering this problem I have a simpler solution.

You have to wrap all "menuItem" in the sideBarMenu() fonction. This will solve the problem and make the items in the menu bigger.

library(shiny)
library(shinydashboard)

shinyUI(dashboardPage(skin = "black",
dashboardHeader(title = h4("Tableau de bord des élections",style =      
"color:navy"),
titleWidth = 300
),
dashboardSidebar(id="", sidebarMenu(
menuItem(h4(strong("Dashboard", align = "center")), tabName = "dashboard"),
menuItem(h4(strong("Prédiction")), tabName = "Prédiction"),
menuItem(h4(strong("Interprétation")), tabName = "Interprétation"))),

dashboardBody(
tabItems(
    tabItem(tabName = "dashboard",h2("Analyse du comportement électoral  des citoyens tunisiens", align="center",style = "color:navy") ),

    tabItem(tabName = "Prédiction", h2("Prédiction du vote",    align="center",style = "color:blue")),
    tabItem(tabName = "Interprétation", h2("Interprétation"))

    )
)))
like image 51
Polar Bear Avatar answered Feb 10 '23 05:02

Polar Bear