dropInput: Dropdown Input

View source: R/input-drop.R

dropInputR Documentation

Dropdown Input

Description

A dropdown menu for selecting a value.

Usage

dropInput(
  inputId,
  choicesNames,
  choicesValues,
  selected = NULL,
  dropUp = FALSE,
  dropWidth = NULL,
  dropMaxHeight = NULL,
  dropPreScrollable = FALSE,
  btnClass = "btn-link",
  width = NULL
)

Arguments

inputId

The input slot that will be used to access the value.

choicesNames

A tagList of HTML tags to show in the dropdown menu.

choicesValues

Vector corresponding to choicesNames for retrieving values server-side.

selected

The initial selected value, must be an element of choicesValues, default to the first item of choicesValues.

dropUp

Open the menu above the button rather than below.

dropWidth

Width of the dropdown menu.

dropMaxHeight

Maximal height for the menu.

dropPreScrollable

Force scroll bar to appear in the menu.

btnClass

Class for buttons in dropdown menu, default is "btn-link", you can use for example "btn-default" to display regular buttons.

width

The width of the input.

See Also

updateDropInput

Examples

if (interactive()) {

  library(shiny)
  library(esquisse)

  ui <- fluidPage(
    tags$h2("Drop Input"),
    dropInput(
      inputId = "mydrop",
      choicesNames = tagList(
        list(icon("home"), style = "width: 100px;"),
        list(icon("flash"), style = "width: 100px;"),
        list(icon("cogs"), style = "width: 100px;"),
        list(icon("fire"), style = "width: 100px;"),
        list(icon("users"), style = "width: 100px;"),
        list(icon("info"), style = "width: 100px;")
      ),
      choicesValues = c("home", "flash", "cogs",
                        "fire", "users", "info"),
      dropWidth = "220px"
    ),
    verbatimTextOutput(outputId = "res")
  )

  server <- function(input, output, session) {
    output$res <- renderPrint({
      input$mydrop
    })
  }

  shinyApp(ui, server)

}

esquisse documentation built on Sept. 18, 2024, 5:09 p.m.