简体   繁体   中英

Alt text for a dropdown menu in shiny

If I'm using Microsoft word and I leave my mouse to hover over the font dropdown menu, this popup appears:

字体的替代文字

It tells you the dropdown menu's name, what it's for and a shortcut to using it.

I have an Rshiny App with a dropdown menu, and I'd like to have a similar system to aid my users. How would I go about doing so?

Here is some code to show where I'm starting from:

library(shiny)

ui <- fixedPage(
  # The alt-text would say "Choose from 3 options"
  fixedRow(selectInput("drop", "Features", choices = c(1,2,3))))

shinyApp(ui, server = function(input, output) {})

How about this

library(shiny)
library(spsComps)
library(magrittr)
ui <- fixedPage(
    # The alt-text would say "Choose from 3 options"
    fixedRow(
        # since the dropdown will expand the element height, place on top or bottom is not ideal.
        column(
            6, 
            # use `bsPopover` for full customization
            selectInput("drop1", "Features", choices = c(1,2,3), width="50%") %>% 
                bsPopover("XX dropdown", "Choose from 3 options", "right")
        ),
        column(
            6, 
            # or the convenient function `bsPop` with preset colors
            selectInput("drop2", "Features", choices = c(1,2,3), width="50%") %>% 
                bsPop("XX dropdown", "Choose from 3 options", "left", status = "primary")
        )
    )
)

shinyApp(ui, server = function(input, output) {})

在此处输入图像描述

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