A shadcn select (listbox popup). input$<inputId> is the selected value or
NULL.
Usage
shad_select(
inputId,
label = NULL,
choices,
selected = NULL,
placeholder = "Select...",
disabled = FALSE,
width = NULL,
description = NULL,
class = NULL,
...
)
shad_select_item(value, label = NULL, disabled = FALSE)
shad_select_group(label, ...)
shad_select_separator()Arguments
- inputId
Input id.
- label
Optional label (wraps in
shad_form_field()).- choices
A named/unnamed vector, or a list mixing
shad_select_item(),shad_select_group(), andshad_select_separator().- selected
Initially selected value.
- placeholder
Trigger placeholder text.
- disabled
If
TRUE, disables the control.- width
CSS width.
- description
Optional help text (wraps in
shad_form_field()).- class
Extra CSS classes.
- ...
For
shad_select_group(), the group's items.- value
The item's value.
See also
Other shadshiny tier-2 components:
shad_calendar(),
shad_checkbox(),
shad_combobox(),
shad_date_picker(),
shad_date_presets(),
shad_form_field(),
shad_input(),
shad_input_group(),
shad_input_otp(),
shad_native_select(),
shad_radio_group(),
shad_slider(),
shad_switch(),
shad_textarea(),
shad_toggle(),
shad_toggle_group()
Examples
shad_select("fruit", choices = c("Apple" = "apple", "Banana" = "banana"),
selected = "banana")
#> <div class="shad-select" data-shad="select" id="fruit">
#> <button type="button" class="shad-select__trigger" role="combobox">
#> <span class="shad-select__value" data-placeholder-text="Select...">Banana</span>
#> <svg class="shad-select__chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
#> </button>
#> <div class="shad-select__content shad-anim-pop" hidden>
#> <button type="button" class="shad-select__scroll-btn" data-dir="up" hidden tabindex="-1" aria-hidden="true"><svg class="shad-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg></button>
#> <div class="shad-select__viewport">
#> <div class="shad-select__item" role="option" data-value="apple" data-state="unchecked">
#> <svg class="shad-select__item-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>
#> Apple
#> </div>
#> <div class="shad-select__item" role="option" data-value="banana" data-state="checked">
#> <svg class="shad-select__item-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>
#> Banana
#> </div>
#> </div>
#> <button type="button" class="shad-select__scroll-btn" data-dir="down" hidden tabindex="-1" aria-hidden="true"><svg class="shad-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg></button>
#> </div>
#> </div>