Create a reactive group of radio buttons. The value of whichever
ds_radio() is checked is reported to Shiny as a single value via
input[[inputId]] — mirroring how Shiny's own radioButtons() works.
Usage
ds_radio_group(
inputId,
label,
choices,
selected = NULL,
size = NULL,
disabled = FALSE,
class = NULL
)Arguments
- inputId
Shiny input ID
- label
The legend text for the group
- choices
Named vector of choices (names are labels, values are values)
- selected
Initially selected value. Defaults to the first choice.
- size
Size variant ("sm", "md", "lg")
- disabled
If TRUE, disables every radio button in the group
- class
Additional CSS classes
Examples
ds_radio_group("opts",
label = "Choose one",
choices = c("Choice A" = "a", "Choice B" = "b", "Choice C" = "c"),
selected = "a"
)
#> <fieldset id="opts" class="ds-fieldset ds-shiny-input">
#> <legend>Choose one</legend>
#> <input id="opts_a" name="opts" class="ds-input" type="radio" value="a" checked/>
#> <label for="opts_a">Choice A</label>
#> <input id="opts_b" name="opts" class="ds-input" type="radio" value="b"/>
#> <label for="opts_b">Choice B</label>
#> <input id="opts_c" name="opts" class="ds-input" type="radio" value="c"/>
#> <label for="opts_c">Choice C</label>
#> </fieldset>