---
title: "init(_:isOn:intent:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/toggle/init(_:ison:intent:)-4lsrf"
---

# init(_:isOn:intent:)

Creates a toggle performing an AppIntent and generates its label from a localized string key.

## Declaration

```swift
nonisolated init(_ titleKey: LocalizedStringKey, isOn: Bool, intent: some AppIntent)
```

## Parameters

- `titleKey`: The key for the toggle’s localized title, that describes the purpose of the toggle.
- `isOn`: Whether the toggle is on or off.
- `intent`: The AppIntent to be performed.

## 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. To initialize a toggle with a string variable, use init(_:isOn:intent:) instead.
