Adding a company Logo to ShinyDashboard header

后端 未结 2 1212
误落风尘
误落风尘 2020-12-01 02:04

So just curious, is there any way to add a company logo to the header of a ShinyDashboard? As I am looking at the documentation, it describes changing the "logo" i

2条回答
  •  执念已碎
    2020-12-01 02:52

    Here's my hack (put your logo, as has been mentioned before, into a www subdirectory of your app directory).
    Because dashboardHeader() expects a tag element of type li and class dropdown, we can pass such elements instead of dropdownMenus:

    library(shiny)
    library(shinydashboard)
    
    dbHeader <- dashboardHeader(title = "My Dashboard",
                                tags$li(a(href = 'http://shinyapps.company.com',
                                          icon("power-off"),
                                          title = "Back to Apps Home"),
                                        class = "dropdown"),
                                tags$li(a(href = 'http://www.company.com',
                                          img(src = 'company_logo.png',
                                              title = "Company Home", height = "30px"),
                                          style = "padding-top:10px; padding-bottom:10px;"),
                                        class = "dropdown"))
    
    server <- function(input, output) {}
    
    shinyApp(
        ui = dashboardPage(
            dbHeader,
            dashboardSidebar(),
            dashboardBody()
        ),
        server = server
    )
    

提交回复
热议问题