0

I am trying to insert an local image inside a tabitem in shiny app, but some challenges and load it on the page. Could someone help to solve this issue? My code attempt is:

CODE

if (interactive()) {
  library(shiny)
  library(shinydashboard)
ui <- dashboardPage(skin = "blue",
                   dashboardHeader(),
                   dashboardSidebar(
                     sidebarMenu(
                       id = "tabs",
                       menuItem("Dogs", icon = icon("dog"), tabName = "Dogs"),
                       menuItem("Data", icon = icon("table"), tabName = "Data")
                   )),
                   dashboardBody(
                     mainPanel(
                       tabItems(
                         tabItem(tabName = "Dogs",  class='active', role="figure",
                                 tags$img(src="dogdogs.png")
                                
                                 )))),
                   tags$head(
                     tags$style(HTML(" .main-sidebar {background-color:  blue;}"))
                   )
                   
                 
              
)

server <- function(input, output) { }

shinyApp(ui, server)
}

Thanks in advance

Phil
  • 7,287
  • 3
  • 36
  • 66
Lola
  • 11
  • 2
  • Where do you have the image saved? See https://stackoverflow.com/questions/21996887/embedding-image-in-shiny-app – Phil Aug 20 '21 at 18:38
  • Hi, Phil, thanks for your reply. It is in the shinyApp/www/ directory, I do no know if I am doing something wrong. It works in mainPanel, but it does not work inside tabItem section. Do I need give even with this the full path? – Lola Aug 20 '21 at 19:31
  • I cannot reproduce the issue: https://i.imgur.com/5QhMTO0.png Check to see if the file is named correctly? – Phil Aug 20 '21 at 19:50
  • Phil thanks so much for this reply. I understood now. I create a directory where i put all the files with same names as the first link that you send before. But the images need to be inside ~/R/shinyApp/www/ .Well, I did and it worked and hope it is right. Thanks again. – Lola Aug 20 '21 at 20:55

0 Answers0