[英]How can I change the background color of the selected menuItem in shinydashboard?
我提供了一個簡單的示例代碼。 如果我選擇了Widgets
,那么Widgets
menuItem的背景色應該改變。
代碼如下
## Only run this example in interactive R sessions
if (interactive()) {
ui <- dashboardPage(
dashboardHeader(title = "Simple tabs"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
h2("Dashboard tab content")
),
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output, session) {
}
}
shinyApp(ui, server)
我應該添加CSS標簽嗎? 先感謝您!
嘗試使用toggleClass函數在CSS類之間進行切換。 用法和示例可以在這里找到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.