Search code examples
rshinyshinybs

Popover / tooltip for a text in shiny app using shinybs


Is there a way to add popover or a tooltip to an

output$Text <- renderText({ c("TestText") }) element, which is then rendered through renderUI, using shinyBS?


Solution

  • Something like this do?

    Base Shiny

    rm(list=ls())
    library(shiny)
    
    ui <- basicPage(
      headerPanel("Tooltip test"),
      mainPanel(
        column(3,tags$div(title="Tooltip works",verbatimTextOutput("Text")))
      )
    )
    
    server <- shinyServer(function(input, output,session) {
      
      output$Text <- renderText({ c("TestText") })
      
    })
    shinyApp(ui = ui, server = server)
    

    enter image description here

    ShinyBS

    rm(list=ls())
    library(shiny)
    library(shinyBS)
    
    ui <- basicPage(
      headerPanel("Tooltip test"),
      bsTooltip("Text", "Tooltip works", placement = "bottom", trigger = "hover",
                options = NULL),
      mainPanel(
        column(3,verbatimTextOutput("Text"))
      )
    )
    
    server <- shinyServer(function(input, output,session) {
      
      output$Text <- renderText({ c("TestText") })
      
    })
    shinyApp(ui = ui, server = server)
    

    enter image description here