Home > Net >  Import the icon of TabPanel from file in R Shiny
Import the icon of TabPanel from file in R Shiny

Time:02-02

I have a simple app and want to add custom icons to my TabPanels

See code


library(shiny)

ui <- fluidPage(
  br(),
  navlistPanel(
    tabPanel('Menu1', icon = icon("bar-chart-o"),
             'Menu One',
             tags$img(src='svg/frame.svg', height='40', width='40')
             
             ),
    tabPanel('Menu2',
             icon = tags$img(src='svg/frame.svg', height='40', width='40'),
             'Menu Two')
  )
)

server <- function(input, output) {
  
}

# Run the application 
shinyApp(ui = ui, server = server)

As you can see, the tag is working well and I can see the svg image (in www/svg)

enter image description here

However it does not render the icon for Menu 2.

CodePudding user response:

Quick solution is

title = div(img(src="svg/frame.svg"), "My Title")

CodePudding user response:

library(shiny)

ui <- fluidPage(
  br(),
  navlistPanel(
    tabPanel('Menu1', icon = icon("bar-chart-o"),
             'Menu One',
             tags$img(src='https://www.svgrepo.com/show/5840/like.svg', height='40', width='40')
             
             ),
    tabPanel(div(img(src='https://www.svgrepo.com/show/5840/like.svg', height='20', width='20'), "Menu2"),
             'Menu Two')
  )
)

server <- function(input, output) {
  
}

# Run the application 
shinyApp(ui = ui, server = server)

enter image description here

  •  Tags:  
  • Related