Below is some simple sample code for shinydashboard
with various subMenuItem
objects under a menuItem
. By default, when the app is deployed the subMenuItem
s are collapsed. Is there a way to set it so that they are not collapsed?
ui <- dashboardPage(
dashboardHeader(title='Head'),
dashboardSidebar(
sidebarMenu(
menuItem('Tabs', tabName='tabs',
menuSubItem('Tab 1', tabName='tab1'),
menuSubItem('Tab 2', tabName='tab2'),
menuSubItem('Tab 3', tabName='tab3')
)
)
),
dashboardBody(
tabItems(
tabItem(tabName='tab1',
h1("Tab 1")
),
tabItem(tabName='tab2',
h1("Tab 2")
),
tabItem(tabName='tab3',
h1("Tab 3")
)
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
You can use Javascript to change the default display style of the menu elements (by default they are display:none
which needs to be changed to display:block
). Add the following line after menuItem()
(remember to add a comma also)
tags$head(tags$script(HTML('$(document).ready(function() {$(".treeview-menu").css("display", "block");})')))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With