← Back to Components

Toggle Group

Segmented single or multiple toggle input for view switchers and toolbars.

Interactive Playground

R Code

API Reference

block_toggle_group()

Segmented toggle group for single or multiple pressed choices (view switchers, toolbars).

ArgumentTypeDefaultDescription
input_idcharacterrequiredInput id; reports a string (single) or character vector (multiple).
choiceslist | characterrequiredChoice labels and values.
selectedcharacterNULLInitial pressed value(s); NULL starts released.
type'single' | 'multiple''single'Selection mode; create-only.
variant'default' | 'outline''default'Borderless or outlined segments.
size'default' | 'sm' | 'lg''default'Item height and padding.
iconsnamed listNULLChoice value to vendored icon name or shiny.tag mapping.
icon_onlylogicalFALSEHide labels visually; labels become aria-label. Requires icons.
disabledlogical | characterFALSEDisable the group, or listed choice values per item.
stylecharacter | listNULLInline CSS styles applied to the group wrapper.
classcharacterNULLAdditional class merged onto the group wrapper.

update_block_toggle_group()

Replaces pressed values, choices, icons, disabled state, variant, or size from the server.

ArgumentTypeDefaultDescription
sessionShinySessionrequiredStandard active R/Shiny session.
input_idcharacterrequiredTarget toggle group input ID.
selectedcharacterNULLNew pressed value(s); NULL releases everything.
choiceslist | characterNULLReplacement choices.
iconsnamed listNULLIcons for the replacement choices; requires choices.
disabledlogical | characterNULLGroup flag or per-item choice values.
variant'default' | 'outline'NULLNew visual variant.
size'default' | 'sm' | 'lg'NULLNew item size.