sssheridan
sssheridan

Reputation: 710

Increase length of tooltip/popover in ShinyBS

The ShinyBS package provides a great and easy way to add tooltips and popovers to elements of a Shiny app. However, the length of these is sharply limited at around 40 characters. I really need to increase the number of characters allowed in these tooltips.

An example:

library(shiny)
library(shinyBS)

shinyApp(
  ui = fluidPage(
      column(5,sliderInput("n", "Short tooltip", 5, 100, 20),
                   bsTooltip("n",title="This is a short tooltip, so it works."),
                   sliderInput("n2", "Long tooltip", 5, 100, 20),
                   bsTooltip("n2",title="This is a longer tooltip, so it doesn't work."))
  ), 
  server = function(input, output) {}
)

Upvotes: 3

Views: 1238

Answers (1)

Josh O'Brien
Josh O'Brien

Reputation: 162321

It's actually the presence of an unescaped ' in that second tooltip's title that's causing you problems, not the title's length. Typing \\' in place of each ' will fix the problem.

Try running this (or, for that matter, the example in ?bsTooltip) to see that tooltips with long titles work just fine:

library(shiny)
library(shinyBS)

shinyApp(
  ui = fluidPage(
      column(5,
             sliderInput("n", "Short tooltip", 5, 100, 20),
             bsTooltip("n",title="This is a short tooltip, so it works."),
             sliderInput("n2", "Long tooltip", 5, 100, 20),
             bsTooltip("n2",title="This is a longer tooltip, which\\'ll still work, as long as each special character is escaped with a \\\\\\\\."))
  ), 
  server = function(input, output) {}
)

Upvotes: 5

Related Questions