5

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

smerllo
  • 3,117
  • 1
  • 22
  • 37
  • Possible duplicate of [Adding a company Logo to ShinyDashboard header](http://stackoverflow.com/questions/31440564/adding-a-company-logo-to-shinydashboard-header) – Tonio Liebrand May 08 '17 at 14:38
  • No it's not the same, I have tried that code but it did not solve my problem. Please try to see the picture I've enclosed with my question. – smerllo May 08 '17 at 14:51
  • then pls share your attempt,...for me it looks the same – Tonio Liebrand May 08 '17 at 15:05
  • 2
    _"I have tried to use the code in the other answers here on stackoverflow"_: Then please share what you have tried, and where you failed. – Axeman May 08 '17 at 15:09
  • Many apologies ! I edited my question. – smerllo May 08 '17 at 15:59

1 Answers1

6

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) {})
Jaehyeon Kim
  • 1,328
  • 11
  • 16