rshinyalt

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:

alt text for fonts

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

Solution

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

    enter image description here