drop-menu-interaction: Interact with Drop Menu

Description Usage Arguments Examples

Description

Interact with Drop Menu

Usage

1
2
3
4
5
6
7
enableDropMenu(id, session = shiny::getDefaultReactiveDomain())

disableDropMenu(id, session = shiny::getDefaultReactiveDomain())

showDropMenu(id, session = shiny::getDefaultReactiveDomain())

hideDropMenu(id, session = shiny::getDefaultReactiveDomain())

Arguments

id

Drop menu ID, the tag's ID followed by "_dropmenu".

session

Shiny session.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
if (interactive()) {
  library(shiny)
  library(shinyWidgets)

  ui <- fluidPage(
    tags$h2("Drop Menu interactions"),
    dropMenu(
      actionButton("myid", "See what's inside"),
      "Drop menu content",
      actionButton("hide", "Close menu"),
      position = "right middle"
    ),
    tags$br(),
    tags$p("Is drop menu opened?"),
    verbatimTextOutput("isOpen"),
    actionButton("show", "show menu"),
    tags$br(),
    tags$br(),
    dropMenu(
      actionButton("dontclose", "Only closeable from server"),
      "Drop menu content",
      actionButton("close", "Close menu"),
      position = "right middle",
      hideOnClick = FALSE
    )
  )

  server <- function(input, output, session) {

    output$isOpen <- renderPrint({
      input$myid_dropmenu
    })

    observeEvent(input$show, {
      showDropMenu("myid_dropmenu")
    })

    observeEvent(input$hide, {
      hideDropMenu("myid_dropmenu")
    })

    observeEvent(input$close, {
      hideDropMenu("dontclose_dropmenu")
    })

  }

  shinyApp(ui, server)
}

Example output



shinyWidgets documentation built on Sept. 17, 2021, 5:06 p.m.