Search code examples
htmlrshinymousehover

Add hover message on icon in R Shiny


I would like to add a hover message which will appear when I move my mouse above the "i" information icon.

info icon

I added the icon with:

numericInput("fixed_ratio", 
             label = tags$div(HTML('Fixed ratio <i class="fas fa-info-circle" 
                                       style = "color:#0072B2;"></i>')), 
             value = 1)

Within the "HTML", I tried to add "title" to work as the hover message, but it didn't work out.

Is there any way to add the message? Thanks!!


Solution

  • This works for me:

    library(shiny)
    
    ui <- fluidPage(
      numericInput(
        "fixed_ratio", 
        label = tags$span(
          "Fixed ratio", 
          tags$i(
            class = "glyphicon glyphicon-info-sign", 
            style = "color:#0072B2;",
            title = "message"
          )
        ), 
        value = 1
      )  
    )
    
    shinyApp(ui, function(input, output){})