Learn R Programming

shiny.semantic (version 0.2.0)

dropdown: Create dropdown Semantic UI component

Description

This creates a default dropdown using Semantic UI styles with Shiny input. Dropdown is already initialized and available under input[[name]].

Usage

dropdown(name, choices, choices_value = choices, default_text = "Select",
  value = NULL)

Arguments

name

Input name. Reactive value is available under input[[name]].

choices

All available options one can select from.

choices_value

What reactive value should be used for corresponding choice.

default_text

Text to be visible on dropdown when nothing is selected.

value

Pass value if you want to initialize selection for dropdown.

Examples

Run this code
# NOT RUN {
## Only run examples in interactive R sessions
if (interactive()) {

  library(shiny)
  library(shiny.semantic)
  ui <- function() {
      shinyUI(
        semanticPage(
          title = "Dropdown example",
          suppressDependencies("bootstrap"),
          uiOutput("dropdown"),
          p("Selected letter:"),
          textOutput("selected_letter")
       )
     )
  }
  server <- shinyServer(function(input, output) {
     output$dropdown <- renderUI({
         dropdown("simple_dropdown", LETTERS, value = "A")
     })
     output$selected_letter <- renderText(input[["simple_dropdown"]])
  })

  shinyApp(ui = ui(), server = server)
}

# }

Run the code above in your browser using DataLab