Shiny: Feature request: easy tooltip component

Created on 26 Sep 2016  路  7Comments  路  Source: rstudio/shiny

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

Intermediate Medium Medium Type

Most helpful comment

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

All 7 comments

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
  )
}

you may get some ideas from ebailey78/shinyBS

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.

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

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.

I used shinyBS:bsPopover to overcome this problem.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HarlanH picture HarlanH  路  3Comments

zji90 picture zji90  路  5Comments

Stophface picture Stophface  路  3Comments

snowman55 picture snowman55  路  5Comments

daattali picture daattali  路  4Comments