Search code examples
shinyshinydashboardshinydashboardplus

Change text in boxSidebar tooltip


I am using boxSidebar for my non-english shiny app, and would really like to replace the 'More' text that appears on hovering over the icon. Can anyone help me with a solution for this?

enter image description here

Alternatively, I was thinking to remove it by using shinyjs::hide(), but the ID seems to change on every hover so I do not know if that's an option here.

minimum example:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

shinyApp(
    ui = dashboardPage(
        header = dashboardHeader(),
        body = dashboardBody(
            box(
                title = "Hover icon", 
                sidebar = boxSidebar(
                    id = "mycardsidebar",
                    p("Sidebar Content")
                )
            )
        ),
        sidebar = dashboardSidebar()
    ),
    server = function(input, output, session) {
    }
)

Solution

  • We can use {htmltools} to do the work:

    library(shiny)
    library(shinydashboard)
    library(shinydashboardPlus)
    library(htmltools)
    library(magrittr)
    shinyApp(
        ui = dashboardPage(
            header = dashboardHeader(),
            body = dashboardBody(
                box(
                    title = "Hover icon", 
                    sidebar = boxSidebar(
                        id = "mycardsidebar",
                        p("Sidebar Content")
                    )
                ) %>% {
                    tagQuery(.)$
                        find("#mycardsidebar")$
                        removeAttrs("data-original-title")$
                        addAttrs(`data-original-title`="whatever")$
                        allTags()
                }
    
            ),
            sidebar = dashboardSidebar()
        ),
        server = function(input, output, session) {
        }
    )
    

    change whatever to your text.

    enter image description here