从本质上讲,我想更换图标中的每个menuItem()
在shinydashboard
与图像。更具体地说,我只需要每个menuItem()
人都有一个图像,然后在其旁边添加文本。
这是我尝试过的一些成功的尝试(在下面的代码中有注释);
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Dashboard MenuItems"),
dashboardSidebar(
sidebarMenu(
id = "tabs",
menuItem(
"Dashboard",
tabName = "dashboard",
## creates a drop down w/ no image
# label = img(src = "logo.png",
# title = "logo", height = "35pt")
## creates a drop down with the images
# `tag$` isn't needed
# tags$img(src = "logo.png",
# title = "logo", height = "35pt")
),
menuItem(
"Not Dashboard",
tabname = "not_dashboard"
)
) # end sidebarMenu
), # end dashboardSidebar
dashboardBody(
fluidRow(
box(
title = "stuff goes here",
width = 12
)
)
) # end dashboardBody
)
server <- function(input, output, session) {
message("You can do it!")
}
shinyApp(ui, server)
我成功地使用了带有背景图像的动作按钮来模拟行为,但是menuItem()
,如果可能的话,我更希望使用s查找解决方案。
我希望会有类似的方法将图片添加到的背景,menuItem()
或将图片与中的文本连接起来menuItem()
。
我对闪亮的标签不好。我对HTML / CSS / JS或Bootstrap的了解不多,大多数时候我都可以在这里找到解决方案,并以自己的方式破解我想要的东西,但是这个问题一直困扰着我。
有任何想法吗?
您可以将图像保存在www文件夹中,并使用div如下图所示将图像和文字包装在一起。
ui <- dashboardPage(
dashboardHeader(title = "Dashboard MenuItems"),
dashboardSidebar(
sidebarMenu(
id = "tabs",
menuItem( div(tags$img(src = "YBS.png", width="20px"), "Dashboard2"),
tabName = "dashboard" # , icon=icon("b_icon")
),
menuItem(
div(tags$img(src = "mouse.png", width="35px"),"Not Dashboard"),
tabname = "not_dashboard" #, icon=icon("home")
)
) # end sidebarMenu
), # end dashboardSidebar
dashboardBody(
fluidRow(
box(
title = "stuff goes here",
width = 12
)
)
) # end dashboardBody
)
server <- function(input, output, session) {
message("You can do it!")
}
shinyApp(ui, server)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句