Skip to content

Button group - Frameworks

Button group is a grouping concept for buttons.

iOSreleasedVuereleased

iOS

Syntax

swift
Warp.ButtonGroup(
    buttons: Binding<[(title: String, isSelected: Bool)]>,
    singleSelect: Bool = false,
    onSelectionChange: (([(String, Bool)]) -> Void)? = nil
)
swift
Warp.ButtonGroup(buttons: $buttons, singleSelect: true) { updatedButtons in
    print("Updated button states:", updatedButtons)
}

Visual options

ButtonGroup can be multi select or single select.

Legacy support

By default all Warp components return a SwiftUI View but there is always a UIKit UIView available to use also.

swift
Warp.ButtonGroup(buttons: $buttons, singleSelect: true) { updatedButtons in
    print("Updated button states:", updatedButtons)
}.uiView

Parameters

Required props

NameTypeDefaultDescription
buttonsBindingA binding to an array of tuples representing each button's title and selection state.

Optional Props

NameTypeDefaultDescription
singleSelectBoolfalseSpecifies the selection behavior. If true, only one button can be selected at a time. If false, multiple buttons can be selected.
onSelectionChange(([(String, Bool)]) -> Void)?nilAn optional closure that receives the updated button array whenever the selection changes.

Questions?

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system