selection/DSRadioGroup

DSRadioGroup

selection
since v1.0

Single-select radio button group. Generic over any Hashable value type.

iOS 17+macOS 14+

Purpose

Mutually exclusive options in forms and settings. Use when all options should be visible at once.

Props

PropTypeDefaultDescription
optionsreq[(label: String, value: T, icon: String?)]Available options.
selectedreqBinding<String>Binding to the selected value.
labelString?nilGroup label.

Examples

Plan selector

Select a subscription plan.

swift
DSRadioGroup(
    options: [
        (label: "Monthly", value: "monthly", icon: nil),
        (label: "Annual — save 20%", value: "annual", icon: "tag"),
    ],
    selected: $billingPeriod
)

Related Components