简体   繁体   中英

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?

在此处输入图像描述

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

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.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM