rstudio/bslib

Formatting within tooltip

tamas-ferenci opened this issue · 3 comments

The options argument of tooltip states that it can be used to set additional options, with a link leading to here. This page has an option called html which theoretically allows the usage of HTML within the tooltip text. However, this does not seem to work: HTML tags are displayed as text with no formatting applied.

Minimal reproducible example:

library(shiny)

ui <- fluidPage(
  
  theme = bslib::bs_theme(bootswatch = "default"),
  
  titlePanel("Old Faithful Geyser Data"),
  
  sidebarLayout(
    sidebarPanel(
      bslib::tooltip(
        bsicons::bs_icon("question-circle"),
        "A <b>formatted</b> text.",
        placement = "right", options = list(html = TRUE))
    ),
    
    mainPanel(
    )
  )
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

Session Info


 Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.3 (2024-02-29 ucrt)
 os       Windows 10 x64 (build 19045)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  Hungarian_Hungary.utf8
 ctype    Hungarian_Hungary.utf8
 tz       Europe/Budapest
 date     2024-03-26
 rstudio  2023.12.1+402 Ocean Storm (desktop)
 pandoc   2.16.1 @ C:\\PROGRA~1\\Pandoc\\pandoc.exe

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.0)
cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.2)
devtools 2.4.5 2022-10-11 [1] CRAN (R 4.3.2)
digest 0.6.35 2024-03-11 [1] CRAN (R 4.3.3)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.0)
fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.1)
glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.2)
htmltools 0.5.8 2024-03-25 [1] CRAN (R 4.3.3)
htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.3.2)
httpuv 1.6.14 2024-01-26 [1] CRAN (R 4.3.2)
later 1.3.2 2023-12-06 [1] CRAN (R 4.3.2)
lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.2)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.3.0)
mime 0.12 2021-09-28 [1] CRAN (R 4.3.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.3.1)
pkgbuild 1.4.4 2024-03-17 [1] CRAN (R 4.3.3)
pkgload 1.3.4 2024-01-16 [1] CRAN (R 4.3.2)
profvis 0.3.8 2023-05-02 [1] CRAN (R 4.3.1)
promises 1.2.1 2023-08-10 [1] CRAN (R 4.3.1)
purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.1)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0)
Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.3.2)
remotes 2.5.0 2024-03-17 [1] CRAN (R 4.3.3)
rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.2)
rstudioapi 0.16.0 2024-03-24 [1] CRAN (R 4.3.3)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.2)
shiny 1.8.1 2024-03-26 [1] CRAN (R 4.3.3)
stringi 1.8.3 2023-12-11 [1] CRAN (R 4.3.2)
stringr 1.5.1 2023-11-14 [1] CRAN (R 4.3.2)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.3.2)
usethis 2.2.3 2024-02-19 [1] CRAN (R 4.3.2)
vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.2)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.0)

The string needs to be wrapped with HTML(). Also the option isn't necessary

bslib::tooltip(
  bsicons::bs_icon("question-circle"),
  HTML("A <b>formatted</b> text."),
  placement = "right"
)

Ah, sorry for not realizing that! Thank you very much, it works perfectly.

This issue has been automatically locked. If you have found a related problem, please open a new issue (with a reproducible example or feature request) and link to this issue.
🙋 Need help? Connect with us on Discord or Posit Community.