bjorn2bewild
bjorn2bewild

Reputation: 1019

Change color of bsTooltip boxes in shiny

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.

Upvotes: 3

Views: 1023

Answers (1)

ek-g
ek-g

Reputation: 721

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.

Upvotes: 4

Related Questions