Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popover / tooltip for a text in shiny app using shinybs

Tags:

r

shiny

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?

like image 913
Claud H Avatar asked Oct 28 '25 08:10

Claud H


2 Answers

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

like image 117
Pork Chop Avatar answered Oct 31 '25 01:10

Pork Chop


In general you can tooltips on any Input and Output object by using their id. For example, I added a tooltip on a downloadButton whose id is downloadData, in the UI.

sidebarPanel(
  downloadButton("downloadData",
    label = "Save and check the Employee List"),
  bsTooltip("downloadData",
     'This is the tooltip where you can add double quotes "like this"'),
      placement = "bottom", trigger = "hover")
)
like image 40
lokxs Avatar answered Oct 31 '25 01:10

lokxs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!