How can I add logo besides project name in shiny dashboard?

[亡魂溺海] 提交于 2019-12-10 10:46:25

问题


Please can you help me to add company logo on the left top of shiny dashboard besides project name.

I have tried to use the code in the other answers here on stackoverflow but still can't solve my problem. I am a total ignorant in HTML and css.

Here is my code:

library(shiny)
library(shinydashboard)
shinyApp(
ui = dashboardPage(skin = "green", 
dashboardHeader(title = "Project name", 
 # this could show the logo but not where I wanted !
 tags$li(a(href = 'http://www.company.com',
              img(src = 'logo.jpg',
              title = "Company Home", height = 30px"),
           style = "padding-top:10px; padding-bottom:10px;"),
                    class = "dropdown"))),
dashboardSidebar(),
dashboardBody()
),
server = function(input, output) {}
)

The picture that shows how I want to add the logo

Thank you


回答1:


It is possible to set an image and text side by side as following.

library(shiny)
library(shinydashboard)

header <- dashboardHeader()
anchor <- tags$a(href='http://www.example.com',
                 tags$img(src='logo.png', height='60', width='50'),
                 'project name')

header$children[[2]]$children <- tags$div(
    tags$head(tags$style(HTML(".name { background-color: black }"))),
    anchor,
    class = 'name')

ui <- dashboardPage(header, dashboardSidebar(), dashboardBody())

shinyApp(ui, server = function(input, output, session) {})


来源:https://stackoverflow.com/questions/43849942/how-can-i-add-logo-besides-project-name-in-shiny-dashboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!