Suggest {shiny.blueprint}R Documentation

Suggest

Description

Documentation: https://blueprintjs.com/docs/#select/suggest2

Usage

Suggest(...)

Suggest.shinyInput(
  inputId,
  items,
  selected = NULL,
  ...,
  noResults = "No results."
)

Arguments

...

Component props and children. See the official Blueprint docs for details.

inputId

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

items

A list of options (character vector or list containing text and label entries)

selected

Initialy selected item

noResults

Message when no results were found

Value

Object with shiny.tag class suitable for use in the UI of a Shiny app.

Examples

library(shiny)
library(shiny.blueprint)

top5Films <- list(
  list(text = "The Shawshank Redemption", label = 1994),
  list(text = "The Godfather", label = 1972),
  list(text = "The Godfather: Part II", label = 1974),
  list(text = "The Dark Knight", label = 2008),
  list(text = "12 Angry Men", label = 1957)
)

ui <- function(id) {
  ns <- NS(id)
  tagList(
    H3("Suggest"),
    Suggest.shinyInput(
      inputId = ns("suggest"),
      items = paste("Option", LETTERS),
      inputProps = list(
        placeholder = "Search with Suggest..."
      )
    ),
    uiOutput(ns("suggest_output")),
    H3("Suggest with labels"),
    Suggest.shinyInput(
      inputId = ns("suggest_lab"),
      items = top5Films,
      noResults = "No suggestions."
    ),
    uiOutput(ns("suggest_lab_output"))
  )
}

server <- function(id) {
  moduleServer(id, function(input, output, session) {
    output$suggest_output <- renderText(input$suggest$text)
    output$suggest_lab_output <- renderText(input$suggest_lab$text)
  })
}

if (interactive()) shinyApp(ui("app"), function(input, output) server("app"))

[Package shiny.blueprint version 0.3.0 Index]