Search code examples
rshinyshinydashboard

Embedding pictures in shinydashboard


Problem: I want to add a second picture to the top right corner in the header. Currently, I am able to place one in the top left corner but not in the top right.

Any suggestions how to do that?

## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
                  header = dashboardHeader( titleWidth = NULL,
                                            title = tags$b("Testapp",
                                                           tags$a(href = 'https://www.google.com/', 
                                                                  tags$img(src = 'mick.png', height = 50, width = 50, align = "left"))
                                            ),

                                              ## QUESTION: how can I add the picture to the top right corner
                                             tags$head(tags$img(src = 'mick.png', height = 50, width = 50, align = "right"))



  ),
  dashboardSidebar(),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)

Solution

  • Shinydashboard expects a li element with class dropdown. If we give it that (replace tags$head(...) with the below):

    tags$li(tags$img(src = 'mick.png', height = 50, width = 50, align = "right"), class = "dropdown")
    

    it works.