<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Toggle/init(_:isOn:intent:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI6ToggleV012_AppIntents_aB0AA4TextVRszrlE_4isOn6intentACyAFGAA18LocalizedStringKeyV_Sbqd__tc0dE00D6IntentRd__lufc::OverloadGroup"
  },
  "title" : "init(_:isOn:intent:)"
}
-->

# init(_:isOn:intent:)

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

```
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

This initializer creates a [`Text`](/documentation/SwiftUI/Text) view on your behalf, and treats the
localized key similar to [`init(_:tableName:bundle:comment:)`](/documentation/SwiftUI/Text/init(_:tableName:bundle:comment:)). See
`Text` for more information about localizing strings.

To initialize a toggle with a string variable, use
[`init(_:isOn:intent:)`](/documentation/SwiftUI/Toggle/init(_:isOn:intent:)) instead.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)