Search code examples
rshinytippyjs

R Shiny - customisation options not working for tippy::with_tippy()


I am trying to position a tooltip to the right of a textInput using the tippy package, however, it isn't working:

library(shiny)
library(tippy)

shinyApp(
  ui = fluidPage(
    with_tippy(textInput("input", "input with tooltip"), "Input text", placement = "right")
 ),
 server = function(input, output) {}
)

The position = 'right', arrow = 'true' and theme = 'light' options also don't seem to be working.

I was wondering if this was a browser compatibility issue or if I'm missing some CSS dependencies on my end? I have tried running the app on Chrome v82.0.4068.5, Firefox 73.0.1 and Microsoft Edge 44.18362.449.0 to no avail.


Solution

  • Your code doesn't run because with_tippy is not a valid function.

    The code below should properly show the position of the tooltip. Important to note: the tippy_this(elementId) refers back to the textInput(inputId) named THISinput here for clarity.

    Instead of actually wrapping the textInput in the tippy_this, we just refer back to the input with elementId.

    library(shiny)
    library(tippy)
    
    shinyApp(
      ui = fluidPage(
        textInput(inputId = "THISinput", "input with tooltip"),
        tippy_this(elementId = "THISinput", tooltip = "Hovertext for 'THISinput' here", placement="right")
      ),
      server = function(input, output) {}
    )