2

Is it possible to style the aesthetics of a tooltip box with bsTooltip in shiny? I have scoured SO for answers, but with respect to tooltips, all of the adjustments on aesthetics appear to be for widths only (ie this question). Consider the MWE from the shinyBS Githug Pages document, including only the bsTooltip portion and some modified CSS:

library(shiny)
library(shinyBS)
shinyApp(
    ui =
        fluidPage(

            sidebarLayout(
                sidebarPanel(
                    tags$style(
                        HTML(
                            "
                        .tooltip {
                        width: 400px;
                        text-color:black;
                        background-color:red;
                        }
                        "

                        )),

                    sliderInput("bins",
                                "Number of bins:",
                                min = 1,
                                max = 50,
                                value = 30),
                    bsTooltip("bins", "The wait times will be broken into this many equally spaced bins",
                              "right")
                ),
                mainPanel(

                )
            )
        ),
    server =
        function(input, output, session) {

        }
)

This results in the following:

enter image description here

It seems as if the div holding the tooltip is changing, but I would like to style the tooltip itself.

Bjørn Kallerud
  • 979
  • 8
  • 23

1 Answers1

3

With .tooltip you are styling the container, try .tooltip-inner, e.g.

tags$style(HTML("
                .tooltip > .tooltip-inner {
                width: 400px;
                color: white;
                background-color: red;
                }
                "))

enter image description here

You can find more tips here.

ek-g
  • 681
  • 3
  • 7
  • Great! With this code, I get the same color for all tooltips. But, can you also tell us how to get different background colors for two/multiple tooltips? I want one to have red background, the other green. – mah65 Jun 05 '21 at 16:43
  • Anyone interested in answer to my question above, refer to here: https://stackoverflow.com/questions/67851936 – mah65 Jun 06 '21 at 00:29