A styled native HTML <select>. Unlike shad_select() (a custom listbox),
this keeps full browser-native behaviour – mobile pickers, form
participation, typeahead – and only bridges the value to Shiny.
input$<inputId> is the selected option value (a string).
Usage
shad_native_select(
inputId,
choices,
selected = NULL,
size = NULL,
disabled = FALSE,
invalid = FALSE,
width = NULL,
label = NULL,
class = NULL,
...
)Arguments
- inputId
Input id.
- choices
A named/unnamed vector for flat options, or a named list of vectors to build
<optgroup>s (names become group labels).- selected
Initially selected value.
- size
One of
NULL(default),"sm","lg".- disabled
If
TRUE, disables the control.- invalid
If
TRUE, setsaria-invalid(destructive styling).- width
CSS width.
- label
Accessible label applied as
aria-labelon the<select>.- class
Extra CSS classes on the root.
- ...
Extra attributes on the root
<div>.
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_radio_group(),
shad_select(),
shad_slider(),
shad_switch(),
shad_textarea(),
shad_toggle(),
shad_toggle_group()
Examples
shad_native_select("tz", choices = list(
Americas = c("America/New_York", "America/Sao_Paulo"),
Europe = c("Europe/London", "Europe/Berlin")
))
#> <div class="shad-native-select" data-shad="native-select" id="tz">
#> <select class="shad-native-select__select">
#> <optgroup label="Americas">
#> <option value="America/New_York">America/New_York</option>
#> <option value="America/Sao_Paulo">America/Sao_Paulo</option>
#> </optgroup>
#> <optgroup label="Europe">
#> <option value="Europe/London">Europe/London</option>
#> <option value="Europe/Berlin">Europe/Berlin</option>
#> </optgroup>
#> </select>
#> <svg class="shad-icon shad-native-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>
#> </div>