dropdownButton: Dropdown Button

Description Usage Arguments Details Note Examples

Description

Create a dropdown menu with Bootstrap where you can put input elements.

Usage

1
2
3
4
dropdownButton(..., circle = TRUE, status = "default",
  size = "default", icon = NULL, label = NULL, tooltip = FALSE,
  right = FALSE, up = FALSE, width = NULL, margin = "10px",
  inputId = NULL)

Arguments

...

List of tag to be displayed into the dropdown menu.

circle

Logical. Use a circle button

status

Add a class to the buttons, you can use Bootstrap status like 'info', 'primary', 'danger', 'warning' or 'success'. Or use an arbitrary strings to add a custom class, e.g. : with status = 'myClass', buttons will have class btn-myClass.

size

Size of the button : default, lg, sm, xs.

icon

An icon to appear on the button.

label

Label to appear on the button. If circle = TRUE and tooltip = TRUE, label is used in tooltip.

tooltip

Put a tooltip on the button, you can customize tooltip with tooltipOptions.

right

Logical. The dropdown menu starts on the right.

up

Logical. Display the dropdown menu above.

width

Width of the dropdown menu content.

margin

Value of the dropdown margin-right and margin-left menu content.

inputId

Optional, id for the button, the button act like an actionButton, and you can use the id to toggle the dropdown menu server-side with toggleDropdownButton.

Details

It is possible to know if a dropdown is open or closed server-side with input$<inputId>_state.

Note

pickerInput doesn't work inside dropdownButton because that's also a dropdown and you can't nest them. Instead use dropdown, it has similar features but is built differently so it works.

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
50
51
52
## Not run: 
## Only run examples in interactive R sessions
if (interactive()) {

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  dropdownButton(
    inputId = "mydropdown",
    label = "Controls",
    icon = icon("sliders"),
    status = "primary",
    circle = FALSE,
    sliderInput(
      inputId = "n",
      label = "Number of observations",
      min = 10, max = 100, value = 30
    ),
    prettyToggle(
      inputId = "na",
      label_on = "NAs keeped",
      label_off = "NAs removed",
      icon_on = icon("check"),
      icon_off = icon("remove")
    )
  ),
  tags$div(style = "height: 140px;"), # spacing
  verbatimTextOutput(outputId = "out"),
  verbatimTextOutput(outputId = "state")
)

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

  output$out <- renderPrint({
    cat(
      " # n\n", input$n, "\n",
      "# na\n", input$na
    )
  })

  output$state <- renderPrint({
    cat("Open:", input$mydropdown_state)
  })

}

shinyApp(ui, server)

}

## End(Not run)

dreamRs/shinyWidgets documentation built on June 5, 2019, 4:07 a.m.