Chili
Chili

Reputation: 45

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) {
    }
)

Upvotes: 1

Views: 118

Answers (1)

lz100
lz100

Reputation: 7350

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

Upvotes: 1

Related Questions