Skip to contents

Create a select dropdown widget

Usage

select(
  options,
  value = NULL,
  prompt = "Select...",
  id = NULL,
  classes = NULL,
  tooltip = NULL
)

Arguments

options

Character vector of options. For unnamed vectors, each string is used as both the display label and returned value. For named vectors, names are returned as values and vector values are displayed as labels.

value

Initial selected value (or NULL for no selection).

prompt

Placeholder text when nothing is selected.

id

Optional widget id.

classes

Optional CSS classes (character vector).

tooltip

Optional tooltip text shown on hover.

Value

An rtui_spec list.

Examples

if (FALSE) { # \dontrun{
quick_app(
  layout = vstack(
    # Simple options
    select(c("Red", "Green", "Blue"), id = "color",
           prompt = "Pick a colour..."),
    # Named options (value = label)
    select(c(s = "Small (S)", m = "Medium (M)", l = "Large (L)"),
           id = "size"),
    static("", id = "result"),
    id = "root"
  ),
  on_change = list(
    color = function(event, state) {
      update(state$app, "result",
             content = paste("Colour:", event$value))
      state
    }
  )
)
} # }