将工具提示添加到Shiny中的navbarMenu

时间:2022-08-26 23:44:42

I would like to add a tooltip for navbarMenu in Shiny app. Similar question asked here but, there is no answer.Here is my reproducible code

我想在Shiny app中为navbarMenu添加工具提示。类似的问题在这里问,但没有答案。这是我可重现的代码

library(shiny)
library(shinyBS)

ui <- shinyUI(fluidPage(
       sidebarLayout( 
           sidebarPanel(),

           mainPanel(tabsetPanel(

             navbarMenu("Tab1",bsTooltip(id="Tab1", title="Short description  for the tab", trigger = "hover"), 
                 tabPanel("Tab1.1"),       
                 tabPanel("Tab1.2")),

            tabPanel("Tab2",tabsetPanel(
                       tabPanel("Tab2.1"),       
                       tabPanel("Tab2.2"))),

            tabPanel("Tab3",tabsetPanel(
                       tabPanel("Tab3.1"),
                       tabPanel("Tab3.2"),
                       tabPanel("Tab3.3")))
)))))
server <- function(input, output) {}
shinyApp(ui = ui, server = server)

During my research I found this solution R Shiny: Use navbarPage with bsModal by shinyBS, but for bsModel. Also, there is a procedure mentioned here which is based in java-script.I know both solutions are for tabpanel but I believe it's the same problem, which is navbarMenu and tabpanel don't have an id.
I'm statistician and I don't have background in HTML or java-script to rewrite the attribute for the tab title or navbarMenu. I hope I phrase my question in a clear manner. Thanks in advance for your time and kind help.

在我的研究过程中,我找到了这个解决方案R Shiny:使用带有bsModal by shinyBS的navbarPage,但是对于bsModel。此外,这里提到的程序基于java脚本。我知道这两个解决方案都适用于tabpanel,但我相信这是同样的问题,即navbarMenu和tabpanel没有id。我是统计学家,我没有HTML或java脚本的背景来重写标签标题或navbarMenu的属性。我希望我能以清楚的方式表达我的问题。在此先感谢您的时间和善意的帮助。

1 个解决方案

#1


2  

you can use HTML wenn passing the Title of the Tabs. in this case I just pt the title in a span and added the attribute titlewhich is the attribute HTML uses default for mouse-overs. For me this is much sinpler the trying to add it over shinyBS.

你可以使用HTML wenn传递标签的标题。在这种情况下,我只是在一个范围内查看标题并添加属性title,这是HTML使用默认鼠标悬停的属性。对我而言,试图将它添加到有光泽的BS上是非常麻烦的。

library(shiny)
library(shinyBS)

ui <- shinyUI(fluidPage(
  sidebarLayout( 
    sidebarPanel(),

    mainPanel(tabsetPanel(

      navbarMenu(span("Tab1",title="Short description  for the tab" ),
                 tabPanel("Tab1.1"),       
                 tabPanel("Tab1.2")),

      tabPanel("Tab2",tabsetPanel(
        tabPanel("Tab2.1"),       
        tabPanel("Tab2.2"))),

      tabPanel("Tab3",tabsetPanel(
        tabPanel("Tab3.1"),
        tabPanel("Tab3.2"),
        tabPanel("Tab3.3")))
    )))))
server <- function(input, output) {}
shinyApp(ui = ui, server = server)

hope this helps!

希望这可以帮助!

#1


2  

you can use HTML wenn passing the Title of the Tabs. in this case I just pt the title in a span and added the attribute titlewhich is the attribute HTML uses default for mouse-overs. For me this is much sinpler the trying to add it over shinyBS.

你可以使用HTML wenn传递标签的标题。在这种情况下,我只是在一个范围内查看标题并添加属性title,这是HTML使用默认鼠标悬停的属性。对我而言,试图将它添加到有光泽的BS上是非常麻烦的。

library(shiny)
library(shinyBS)

ui <- shinyUI(fluidPage(
  sidebarLayout( 
    sidebarPanel(),

    mainPanel(tabsetPanel(

      navbarMenu(span("Tab1",title="Short description  for the tab" ),
                 tabPanel("Tab1.1"),       
                 tabPanel("Tab1.2")),

      tabPanel("Tab2",tabsetPanel(
        tabPanel("Tab2.1"),       
        tabPanel("Tab2.2"))),

      tabPanel("Tab3",tabsetPanel(
        tabPanel("Tab3.1"),
        tabPanel("Tab3.2"),
        tabPanel("Tab3.3")))
    )))))
server <- function(input, output) {}
shinyApp(ui = ui, server = server)

hope this helps!

希望这可以帮助!