rstudio / shiny

Easy interactive web applications with R
https://shiny.posit.co/
Other
5.35k stars 1.87k forks source link

Feature request: easy tooltip component #1390

Open bborgesr opened 7 years ago

bborgesr commented 7 years ago

This could be a question mark or another icon that shows a tooltip when you click or mouse over.

shapenaji commented 7 years ago

In the meantime, I have a simple one that I've been using, it requires shinydashboard though for the bootstrap library

#' tooltipIcon, places text in hover over to guide users
#'
#' @param text text to include in tooltip
#' @param ... shiny objects to tooltip
#' @param link link location, or no link location if '#'
#' @param trigger what triggers the tooltip, see bootstrap documentation for more options
#' @param dataplacement where to place the tooltip relative to the icon, see bootstrap documentation
#'
#' @return a shiny object containing the given tooltip
#' @export
#' 
#' @examples
#' # Required to load bootstrap library
#' library(shinydashboard) 
#' tooltipIcon('This is text that will be shown on hover over', icon('question-circle'))
tooltipIcon <- function(text, ...,
                        link = '#', 
                        trigger = 'focus hover', 
                        dataplacement = "auto bottom") {
  tags$a(
    ...,
    href = link,
    `data-toggle` = 'tooltip', 
    `data-placement` = dataplacement,
    `data-trigger` = trigger,
    title = text
  )
}
shrektan commented 7 years ago

you may get some ideas from ebailey78/shinyBS

zji90 commented 7 years ago

The tooltip provided by shinyBS package breaks (does not show up) in many situations. A well tested tooltip function incorporated directly in shiny would be very helpful.

DarioS commented 7 years ago

shinyBS isn't being maintained any more. I would recommend to avoid it as much as possible.

zji90 commented 7 years ago

I agree that we should avoid shinyBS in the future. However, the features in shinyBS is really nice. I really want to see them incorporated in the shiny main package.

shosaco commented 7 years ago

I used shinyBS:bsPopover to overcome this problem.

riccardoporreca commented 5 years ago

I know this thread is pretty old, but there is now a package bsplus we are gradually replacing shinyBS with.