Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 212
smerllo Avatar asked May 08 '17 14:05

smerllo


Video Answer


1 Answers

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) {})
like image 85
Jaehyeon Kim Avatar answered Sep 19 '22 12:09

Jaehyeon Kim