SwitchView
SwitchViewprovides a Fiori style title andToggle.
/// Inputs
- title: A
ViewBuilderclosure that renders the title content (required). - isOn: A binding to a Boolean value that controls the toggle state (required).
- stateLabel: An optional
ViewBuilderclosure for custom state text. It is only effective when the controlState is.readOnly. It will replace the toggle which usually shows as On or Off . - icon: An optional
ViewBuilderclosure for an icon in the informationView. - description: An optional
ViewBuilderclosure for descriptive text in the informationView. - controlState: The interaction state of the switch (default: .normal). Options: .normal, .disabled, .readOnly.
Usage
@State var isOn: Bool = true
SwitchView(title: "Switch", isOn: self.$isOn)
SwitchView(title: "Switch", isOn: self.$isOn, stateLabel: self.isOn ? "Open" : "Close", description: "Locked by your organization", controlState: .readOnly)
.informationViewStyle(.warning)
-
Undocumented
Declaration
Swift
public init(@ViewBuilder title: () -> any View, isOn: Binding<Bool>, @ViewBuilder stateLabel: () -> any View = { EmptyView() }, @ViewBuilder icon: () -> any View = { EmptyView() }, @ViewBuilder description: () -> any View = { EmptyView() }, controlState: ControlState = .normal, componentIdentifier: String? = SwitchView.identifier) -
Undocumented
Declaration
Swift
static let identifier: String -
Undocumented
Declaration
Swift
init(title: AttributedString, isOn: Binding<Bool>, stateLabel: AttributedString? = nil, icon: Image? = nil, description: AttributedString? = nil, controlState: ControlState = .normal) -
Undocumented
Declaration
Swift
init(_ configuration: SwitchViewConfiguration) -
Declaration
Swift
@MainActor public var body: some View { get } -
Undocumented
Declaration
Swift
public var isEmpty: Bool { get }