dropdownButton: Bootstrap Dropdown Button Module

Description Usage Arguments Functions Usage Examples

View source: R/dropdownButton.R

Description

Creates a bootstrap dropdown button UI, with a server module that returns the id of the most recently clicked button.

Usage

1
2
3
4
5
6
dropdownButtonUI(id, options, label = "Options", type = "dropdown",
  buttonId = paste0(id, "-dropdown"), class = "btn-default")

dropdownButton(id, options)

dropdownButtonDemo(display.mode = c("showcase", "normal", "auto"))

Arguments

id

The shared id of the dropdownButtonUI() and the dropdownButton() module

options

A named vector of options and labels. The name is the label that will appear on the button and the value is the id of the input that is returned from the Shiny modules.

label

The button text of the "master" button containing the dropdown buttons.

type

Type of dropdown: one of "dropdown" or "dropup"

buttonId

The HTML id of the dropdown button.

class

CSS classes to be added to the dropdown button.

display.mode

The mode in which to display the application. If set to the value "showcase", shows application code and metadata from a DESCRIPTION file in the application directory alongside the application. If set to "normal", displays the application normally. Defaults to "auto", which displays the application in the mode given in its DESCRIPTION file, if any.

Functions

Usage

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
if (interactive()) {
  library(shiny)

  button_options <- c(
    "Option A" = "opt_a",
    "Option B" = "opt_b"
  )

  ui <- fluidPage(
    dropdownButtonUI(
      id = "dropdown",
      options = button_options,
      label = "Options"
    ),
    verbatimTextOutput("chosen")
  )

  server <- function(input, output) {
    last_clicked <- dropdownButton("dropdown", button_options)
    output$chosen <- renderPrint({ last_clicked() })
  }

  shinyApp(ui = ui, server = server)
}

gadenbuie/shinyThings documentation built on Nov. 24, 2019, 6:56 p.m.