I'm trying to include badgeLabel
into the menuSubItem
like this:
sidebarMenu(id="tabs",
menuItem("First Item",tabName="Item1"),
menuItem("Secon Item", tabName = "Item2", icon = icon("bell"),
menuSubItem("Sub Item1",tabName="subI1"),
menuSubItem("Sub Item2",tabName="subI2", badgeLabel = "beta", badgeColor = "blue")
)
)
But I get the error:
Error in menuSubItem("Sub Item2", tabName = "subI2", badgeLabel = "beta", : unused arguments (badgeLabel = "beta", badgeColor = "blue")
If I put it in menuItem
, it works just fine, but I need it in menuSubItem
. Any sugestions?
menuSubItem
does not have this argument. Thus you would need to write your own menuSubItem
function:
menuSubItem2 <- function (text, tabName = NULL, href = NULL, newtab = TRUE,
icon = shiny::icon("angle-double-right"),
selected = NULL, badgeLabel = NULL, badgeColor = "green") {
if (!is.null(href) && !is.null(tabName)) {
stop("Can't specify both href and tabName")
}
isTabItem <- FALSE
target <- NULL
if (!is.null(badgeLabel)) {
badgeTag <- tags$small(class = paste0("badge pull-right bg-",
badgeColor), badgeLabel)
}
else {
badgeTag <- NULL
}
if (!is.null(tabName)) {
shinydashboard:::validateTabName(tabName)
isTabItem <- TRUE
href <- paste0("#shiny-tab-", tabName)
}
else if (is.null(href)) {
href <- "#"
}
else {
if (newtab)
target <- "_blank"
}
tags$li(a(href = href, `data-toggle` = if (isTabItem)
"tab", `data-value` = if (!is.null(tabName))
tabName, `data-start-selected` = if (isTRUE(selected))
1
else NULL, target = target, icon, span(text), badgeTag))
}
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.