| glassSelect | R Documentation |
A stylized single-select Shiny input with optional search, clear control,
selection-marker styling, and programmatic updates via updateGlassSelect().
glassSelect(
inputId,
choices,
selected = NULL,
label = NULL,
placeholder = "Select an option",
searchable = TRUE,
clearable = FALSE,
include_all = FALSE,
all_choice_label = "All categories",
all_choice_value = "__all__",
check_style = c("checkbox", "check-only", "filled"),
theme = "dark",
shape = c("rounded", "square"),
width = NULL,
disabled = FALSE,
disabled_choices = NULL,
server = FALSE,
server_limit = 50L,
server_min_chars = 0L
)
inputId |
Shiny input id. |
choices |
Named or unnamed character vector of choices. |
selected |
Initially selected value. Defaults to |
label |
Optional field label shown above the widget. |
placeholder |
Trigger label when nothing is selected. |
searchable |
Logical. Show search input inside dropdown? Default
|
clearable |
Logical. Show clear control for removing the current
selection? Default |
include_all |
Logical. Prepend an explicit "All" option. Default
|
all_choice_label |
Label used for the explicit "All" option. |
all_choice_value |
Value used for the explicit "All" option. |
check_style |
One of |
theme |
Color theme. One of |
shape |
Corner style for the trigger and dropdown. One of
|
width |
Optional widget width passed to
|
disabled |
Logical. When |
disabled_choices |
Optional character vector of choice values to render
as disabled (non-selectable) rows. Default |
server |
Logical. If |
server_limit |
Maximum number of choices rendered initially and returned
for each server-side search. Default |
server_min_chars |
Minimum search characters required before server-side
matching filters choices. Default |
The widget registers one Shiny input:
input$<inputId> : selected value as a length-1 character string,
or NULL when nothing is selected
An htmltools::tagList containing the single-select trigger,
dropdown panel, and scoped <style> block.
Other glass select widgets:
glassMultiSelect(),
glassMultiSelectServer(),
glassMultiSelectValue(),
glassSelectServer(),
glassSelectValue(),
updateGlassMultiSelect(),
updateGlassSelect()
fruits <- c(Apple = "apple", Banana = "banana", Cherry = "cherry")
fruit_select <- glassSelect("fruit", fruits)
selected_fruit <- glassSelect(
"fruit",
fruits,
selected = "banana",
clearable = TRUE
)
all_fruits <- glassSelect(
"fruit",
fruits,
include_all = TRUE,
all_choice_label = "All fruits",
all_choice_value = "__all__"
)
filled_fruit <- glassSelect(
"fruit",
fruits,
check_style = "filled"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.