问题
Is there any way to have right sidebar open by default in shinydashboardPlus?
library(shiny)
library(shinydashboard)
shinyApp(
ui = dashboardPagePlus(
header = dashboardHeaderPlus(
enable_rightsidebar = TRUE,
rightSidebarIcon = "gears"
),
sidebar = dashboardSidebar(),
body = dashboardBody(),
rightsidebar = rightSidebar(
background = "dark",
rightSidebarTabContent(
id = 1,
title = "Tab 1",
icon = "desktop",
active = TRUE,
sliderInput(
"obs",
"Number of observations:",
min = 0, max = 1000, value = 500
)
)
),
title = "Right Sidebar"
),
server = function(input, output) { }
)
回答1:
You have to add the css class control-sidebar-open
to the body tag of your dashboard.
This can be done as follows:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = tags$body(class="skin-blue sidebar-mini control-sidebar-open", dashboardPagePlus(
header = dashboardHeaderPlus(
enable_rightsidebar = TRUE,
rightSidebarIcon = "gears"
),
sidebar = dashboardSidebar(),
body = dashboardBody(
),
rightsidebar = rightSidebar(
background = "dark",
rightSidebarTabContent(
id = 1,
title = "Tab 1",
icon = "desktop",
active = TRUE,
sliderInput(
"obs",
"Number of observations:",
min = 0, max = 1000, value = 500
)
)
),
title = "Right Sidebar"
)),
server = function(input, output) {
}
)
Please find some related info here and here.
来源:https://stackoverflow.com/questions/58756854/right-sidebar-open-by-default-in-shinydashboardplus