rtooltipshinydashboardboxbs4dash

How to add tooltip to box header items in shinyDashbord


I have a simple shinyDashbord app with a box that has a sidebar in it. I would like to add tooltip to the sidebar icon in the box header so that when I hover the mouse over the icon, the tooltip shows up. Is that possible?

# Toggle a box sidebar
library(shiny)
library(bs4Dash)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    body = dashboardBody(
      box(
        height = "500px",
        width = 12,
        maximizable = T,
        solidHeader = FALSE,
        collapsible = TRUE,
        sidebar = boxSidebar(
          id = "mycardsidebar",
          width = 30,
          p("Sidebar Content")
        ) 
      ),
    ),
    sidebar = dashboardSidebar()
  ),
  server = function(input, output, session) {
  }
)

Appreciate any help


Solution

  • There is concise documentation at https://github.com/RinteRface/bs4Dash/issues/267

    # Toggle a box sidebar
    library(shiny)
    library(bs4Dash)
    
    sidebar <- boxSidebar(
      id = "mycardsidebar",
      width = 30,
      p("Sidebar Content")
    ) 
    
    sidebar[[1]]$attribs$`data-original-title` <- "Custom tooltip display"
    
    shinyApp(
      ui = dashboardPage(
        help = TRUE,
        header = dashboardHeader(),
        body = dashboardBody(
          box(
            height = "500px",
            width = 12,
            maximizable = T,
            solidHeader = FALSE,
            collapsible = TRUE,
            sidebar = sidebar
          ),
        ),
        sidebar = dashboardSidebar()
      ),
      server = function(input, output, session) {
      }
    )
    

    tooltip example