闪亮的仪表板 - 动态侧边栏图标

时间:2016-07-08 13:01:01

标签: icons shiny sidebar dashboard

我正在尝试根据我正在运行的当前测试的状态(可能是“Live”或“Archived”)动态更改侧边栏图标。我已经尝试过以下方法将图标的值分配给无功输出,但我无法使其工作。

ui.R

  menuItem("AB calculator ", tabName = "calculator", icon = icon("hand-o-right")),
  menuItem("AB calculator ", tabName = "test1", icon = icon(uiOutput('iconTest')))

server.R

      output$iconTest<-renderUI({
      "th"
      })

这是一个可重现的例子

library(shiny)

shinyApp(
  ui = bootstrapPage(

    dashboardHeader(
      title=" dashboard",
      titleWidth = 250

    ),

    dashboardSidebar(

     sidebarMenu(

        menuItem("AB calculator ", tabName = "test1", icon = icon(uiOutput('iconTest')))

      )
    ),

    dashboardBody(
    )

),
    server = function(input, output) {
      output$iconTest<-renderUI({
        iconTest<-"th"
      })

    }
  )

由于

1 个答案:

答案 0 :(得分:0)

也许你可以呈现整个menuItem

rm(list = ls())
library(shiny)
library(shinydashboard)

shinyApp(
  ui = bootstrapPage(
    dashboardHeader(title=" dashboard"),
    dashboardSidebar(sidebarMenu( uiOutput('iconTest'))),
    dashboardBody()
  ),
  server = function(input, output) {
    output$iconTest <- renderUI({
      menuItem("AB calculator ", tabName = "test1", icon = icon('th'))
    })
  }
)
shinyApp(ui = ui, server = server)

enter image description here