How can I insert and display icons on a selectInput() choices?

Hello RStudio Community :wave:, I want to display icons on the choices of a selectInput(). Sadly, I haven't found out how to achieve this. I was wondering if somebody here has achieved this, thanks.

Here is a sample Shiny App with the idea (although it doesn't work as expected):

library(shiny)

ui <- fluidPage(
  selectInput(
    inputId = "si", 
    label = "Select Input:",
    choices = c(
      paste("item1", icon("gem")), 
      "item2", 
      "item3"
      )
  ),
  
  p("This is a Font Awesome icon (I want at the right side of 'item1'): ",  icon("crown"))
)

server <- function(input, output, session) {
  
}

shinyApp(ui, server)

The icon("gem") on the selectInput() just displays the raw html code <i class="fa fa-gem"></i>.

My result is this:
image

What I want is to include the icon as part of the choice on the select input, kinda like the next example:
image

Is this even possible in Shiny? Thanks.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.