---
title: "init(_:systemImage:sources:isOn:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/toggle/init(_:systemimage:sources:ison:)"
---

# init(_:systemImage:sources:isOn:)

Creates a toggle representing a collection of values that generates its label from a localized string key and system image.

## Declaration

```swift
nonisolated init<C>(_ titleKey: LocalizedStringKey, systemImage: String, sources: C, isOn: KeyPath<C.Element, Binding<Bool>>) where C : RandomAccessCollection
```

## Parameters

- `titleKey`: The key for the toggle’s localized title, that describes the purpose of the toggle.
- `systemImage`: The name of the image resource to lookup.
- `sources`: A collection of values used as the source for rendering the Toggle’s state.
- `isOn`: The key path of the values that determines whether the toggle is on, mixed or off.

## Discussion

Discussion This initializer creates a Text view on your behalf, and treats the localized key similar to init(_:tableName:bundle:comment:). See Text for more information about localizing strings. The following example creates a single toggle that represents the state of multiple alarms: struct Alarm: Hashable, Identifiable {     var id = UUID()     var isOn = false     var name = "" }

@State private var alarms = [     Alarm(isOn: true, name: "Morning"),     Alarm(isOn: false, name: "Evening") ]

Toggle("Enable all alarms", sources: $alarms, isOn: \.isOn)

## See Also

### Creating a toggle for a collection

- [init(_:sources:isOn:)](swiftui/toggle/init(_:sources:ison:).md)
- [init(sources:isOn:label:)](swiftui/toggle/init(sources:ison:label:).md)
- [init(_:image:sources:isOn:)](swiftui/toggle/init(_:image:sources:ison:).md)
